CreateTokenStorage creates a new KimiTokenStorage from auth bundle.
(bundle *KimiAuthBundle)
| 76 | |
| 77 | // CreateTokenStorage creates a new KimiTokenStorage from auth bundle. |
| 78 | func (k *KimiAuth) CreateTokenStorage(bundle *KimiAuthBundle) *KimiTokenStorage { |
| 79 | expired := "" |
| 80 | if bundle.TokenData.ExpiresAt > 0 { |
| 81 | expired = time.Unix(bundle.TokenData.ExpiresAt, 0).UTC().Format(time.RFC3339) |
| 82 | } |
| 83 | return &KimiTokenStorage{ |
| 84 | AccessToken: bundle.TokenData.AccessToken, |
| 85 | RefreshToken: bundle.TokenData.RefreshToken, |
| 86 | TokenType: bundle.TokenData.TokenType, |
| 87 | Scope: bundle.TokenData.Scope, |
| 88 | DeviceID: strings.TrimSpace(bundle.DeviceID), |
| 89 | Expired: expired, |
| 90 | Type: "kimi", |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // DeviceFlowClient handles the OAuth2 device flow for Kimi. |
| 95 | type DeviceFlowClient struct { |
no test coverage detected