fix: maintain OAuth scopes during Google Antigravity token refresh

This commit is contained in:
Andres Sabini 2026-03-29 10:06:32 -03:00
parent 187b2c2185
commit b713711416

View file

@ -393,8 +393,12 @@ func RefreshAccessToken(cred *AuthCredential, cfg OAuthProviderConfig) (*AuthCre
"client_id": {cfg.ClientID}, "client_id": {cfg.ClientID},
"grant_type": {"refresh_token"}, "grant_type": {"refresh_token"},
"refresh_token": {cred.RefreshToken}, "refresh_token": {cred.RefreshToken},
"scope": {"openid profile email"},
} }
scopes := cfg.Scopes
if scopes == "" {
scopes = "openid profile email"
}
data.Set("scope", scopes)
if cfg.ClientSecret != "" { if cfg.ClientSecret != "" {
data.Set("client_secret", cfg.ClientSecret) data.Set("client_secret", cfg.ClientSecret)
} }
@ -545,11 +549,13 @@ func parseTokenResponse(body []byte, provider string) (*AuthCredential, error) {
AuthMethod: "oauth", AuthMethod: "oauth",
} }
// Recent OpenAI OAuth responses may only include chatgpt_account_id in id_token claims. if accountID := extractAccountID(tokenResp.IDToken); accountID != "" {
if id := extractAccountID(tokenResp.IDToken); id != "" { cred.AccountID = accountID
cred.AccountID = id } else if accountID := extractAccountID(tokenResp.AccessToken); accountID != "" {
} else if id := extractAccountID(tokenResp.AccessToken); id != "" { cred.AccountID = accountID
cred.AccountID = id } else if accountID := extractAccountID(tokenResp.IDToken); accountID != "" {
// Recent OpenAI OAuth responses may only include chatgpt_account_id in id_token claims.
cred.AccountID = accountID
} }
return cred, nil return cred, nil