Documentation
¶
Overview ¶
Package kimi provides token refresh for Kimi (Moonshot AI) credentials used by the scheduler.
Index ¶
- type DeviceCodeResponse
- type DeviceFlowClient
- func (c *DeviceFlowClient) PollForToken(ctx context.Context, deviceCode *DeviceCodeResponse) (*KimiTokenData, error)
- func (c *DeviceFlowClient) RefreshToken(ctx context.Context, refreshToken string) (*KimiTokenData, error)
- func (c *DeviceFlowClient) RequestDeviceCode(ctx context.Context) (*DeviceCodeResponse, error)
- type KimiAuth
- type KimiAuthBundle
- type KimiTokenData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeviceCodeResponse ¶
type DeviceFlowClient ¶
type DeviceFlowClient struct {
// contains filtered or unexported fields
}
DeviceFlowClient is a minimal Kimi OAuth client used for refresh-token exchange.
func NewDeviceFlowClient ¶
func NewDeviceFlowClient(cfg *config.Config) *DeviceFlowClient
NewDeviceFlowClient creates a new device flow client.
func NewDeviceFlowClientWithDeviceID ¶
func NewDeviceFlowClientWithDeviceID(cfg *config.Config, deviceID string) *DeviceFlowClient
NewDeviceFlowClientWithDeviceID creates a new device flow client with device id.
func NewDeviceFlowClientWithDeviceIDAndProxyURL ¶
func NewDeviceFlowClientWithDeviceIDAndProxyURL(cfg *config.Config, deviceID string, proxyURL string) *DeviceFlowClient
NewDeviceFlowClientWithDeviceIDAndProxyURL creates a new refresh client with proxy override. proxyURL takes precedence over cfg.ProxyURL when non-empty.
func (*DeviceFlowClient) PollForToken ¶
func (c *DeviceFlowClient) PollForToken(ctx context.Context, deviceCode *DeviceCodeResponse) (*KimiTokenData, error)
PollForToken converts poll for token.
func (*DeviceFlowClient) RefreshToken ¶
func (c *DeviceFlowClient) RefreshToken(ctx context.Context, refreshToken string) (*KimiTokenData, error)
RefreshToken exchanges a refresh token for a new access token.
func (*DeviceFlowClient) RequestDeviceCode ¶
func (c *DeviceFlowClient) RequestDeviceCode(ctx context.Context) (*DeviceCodeResponse, error)
RequestDeviceCode handles request device code.
type KimiAuth ¶
type KimiAuth struct {
// contains filtered or unexported fields
}
func NewKimiAuth ¶
NewKimiAuth creates a new kimi auth.
func (*KimiAuth) StartDeviceFlow ¶
func (k *KimiAuth) StartDeviceFlow(ctx context.Context) (*DeviceCodeResponse, error)
StartDeviceFlow starts a device flow.
func (*KimiAuth) WaitForAuthorization ¶
func (k *KimiAuth) WaitForAuthorization(ctx context.Context, deviceCode *DeviceCodeResponse) (*KimiAuthBundle, error)
WaitForAuthorization returns a wait for authorization.
type KimiAuthBundle ¶
type KimiAuthBundle struct {
TokenData *KimiTokenData
DeviceID string
}
type KimiTokenData ¶
type KimiTokenData struct {
// AccessToken is the OAuth2 access token.
AccessToken string `json:"access_token"`
// RefreshToken is the OAuth2 refresh token.
RefreshToken string `json:"refresh_token"`
// TokenType is the type of token, typically "Bearer".
TokenType string `json:"token_type"`
// ExpiresAt is the Unix timestamp when the token expires.
ExpiresAt int64 `json:"expires_at"`
// Scope is the OAuth2 scope granted to the token.
Scope string `json:"scope"`
}
KimiTokenData holds the raw OAuth token response from Kimi.