CodexTokenStorage stores OAuth2 token information for OpenAI Codex API authentication. It maintains compatibility with the existing auth system while adding Codex-specific fields for managing access tokens, refresh tokens, and user account information.
| 16 | // It maintains compatibility with the existing auth system while adding Codex-specific fields |
| 17 | // for managing access tokens, refresh tokens, and user account information. |
| 18 | type CodexTokenStorage struct { |
| 19 | // IDToken is the JWT ID token containing user claims and identity information. |
| 20 | IDToken string `json:"id_token"` |
| 21 | // AccessToken is the OAuth2 access token used for authenticating API requests. |
| 22 | AccessToken string `json:"access_token"` |
| 23 | // RefreshToken is used to obtain new access tokens when the current one expires. |
| 24 | RefreshToken string `json:"refresh_token"` |
| 25 | // AccountID is the OpenAI account identifier associated with this token. |
| 26 | AccountID string `json:"account_id"` |
| 27 | // LastRefresh is the timestamp of the last token refresh operation. |
| 28 | LastRefresh string `json:"last_refresh"` |
| 29 | // Email is the OpenAI account email address associated with this token. |
| 30 | Email string `json:"email"` |
| 31 | // Type indicates the authentication provider type, always "codex" for this storage. |
| 32 | Type string `json:"type"` |
| 33 | // Expire is the timestamp when the current access token expires. |
| 34 | Expire string `json:"expired"` |
| 35 | |
| 36 | // Metadata holds arbitrary key-value pairs injected via hooks. |
| 37 | // It is not exported to JSON directly to allow flattening during serialization. |
| 38 | Metadata map[string]any `json:"-"` |
| 39 | } |
| 40 | |
| 41 | // SetMetadata allows external callers to inject metadata into the storage before saving. |
| 42 | func (ts *CodexTokenStorage) SetMetadata(meta map[string]any) { |
nothing calls this directly
no outgoing calls
no test coverage detected