fix: avoid temp unsched when refresh token is missing
This commit is contained in:
@@ -502,6 +502,25 @@ func (s *OpenAIOAuthService) RefreshAccountToken(ctx context.Context, account *A
|
||||
|
||||
refreshToken := account.GetCredential("refresh_token")
|
||||
if refreshToken == "" {
|
||||
accessToken := account.GetCredential("access_token")
|
||||
if accessToken != "" {
|
||||
tokenInfo := &OpenAITokenInfo{
|
||||
AccessToken: accessToken,
|
||||
RefreshToken: "",
|
||||
IDToken: account.GetCredential("id_token"),
|
||||
ClientID: account.GetCredential("client_id"),
|
||||
Email: account.GetCredential("email"),
|
||||
ChatGPTAccountID: account.GetCredential("chatgpt_account_id"),
|
||||
ChatGPTUserID: account.GetCredential("chatgpt_user_id"),
|
||||
OrganizationID: account.GetCredential("organization_id"),
|
||||
PlanType: account.GetCredential("plan_type"),
|
||||
}
|
||||
if expiresAt := account.GetCredentialAsTime("expires_at"); expiresAt != nil {
|
||||
tokenInfo.ExpiresAt = expiresAt.Unix()
|
||||
tokenInfo.ExpiresIn = int64(time.Until(*expiresAt).Seconds())
|
||||
}
|
||||
return tokenInfo, nil
|
||||
}
|
||||
return nil, infraerrors.New(http.StatusBadRequest, "OPENAI_OAUTH_NO_REFRESH_TOKEN", "no refresh token available")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user