kimi

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package kimi provides token refresh for Kimi (Moonshot AI) credentials used by the scheduler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri,omitempty"`
	VerificationURIComplete string `json:"verification_uri_complete"`
	ExpiresIn               int    `json:"expires_in"`
	Interval                int    `json:"interval"`
}

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

func NewKimiAuth(cfg *config.Config) *KimiAuth

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL