mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 04:40:59 +00:00
* feat: codex channel * feat: codex channel * feat: codex oauth flow * feat: codex refresh cred * feat: codex usage * fix: codex err message detail * fix: codex setting ui * feat: codex refresh cred task * fix: import err * fix: codex store must be false * fix: chat -> responses tool call * fix: chat -> responses tool call
31 lines
798 B
Go
31 lines
798 B
Go
package codex
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/QuantumNous/new-api/common"
|
|
)
|
|
|
|
type OAuthKey struct {
|
|
IDToken string `json:"id_token,omitempty"`
|
|
AccessToken string `json:"access_token,omitempty"`
|
|
RefreshToken string `json:"refresh_token,omitempty"`
|
|
|
|
AccountID string `json:"account_id,omitempty"`
|
|
LastRefresh string `json:"last_refresh,omitempty"`
|
|
Email string `json:"email,omitempty"`
|
|
Type string `json:"type,omitempty"`
|
|
Expired string `json:"expired,omitempty"`
|
|
}
|
|
|
|
func ParseOAuthKey(raw string) (*OAuthKey, error) {
|
|
if raw == "" {
|
|
return nil, errors.New("codex channel: empty oauth key")
|
|
}
|
|
var key OAuthKey
|
|
if err := common.Unmarshal([]byte(raw), &key); err != nil {
|
|
return nil, errors.New("codex channel: invalid oauth key json")
|
|
}
|
|
return &key, nil
|
|
}
|