oauthutil: avoid panic when `*token` and `*ts.token` are the same

the field `raw` of `oauth2.Token` may be an uncomparable type(often map[string]interface{}), causing `*token != *ts.token` expression to panic(comparing uncomparable type ...).

the semantics of comparing whether two tokens are the same can be achieved by comparing accessToken, refreshToken and expire to avoid panic.
This commit is contained in:
rkonfj 2024-01-03 20:25:42 +08:00 committed by Nick Craig-Wood
parent d977fa25fa
commit 451d7badf7
1 changed files with 1 additions and 1 deletions

View File

@ -292,7 +292,7 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) {
if err != nil {
return nil, fmt.Errorf("couldn't fetch token: %w", err)
}
changed = changed || (*token != *ts.token)
changed = changed || token.AccessToken != ts.token.AccessToken || token.RefreshToken != ts.token.RefreshToken || token.Expiry != ts.token.Expiry
ts.token = token
if changed {
// Bump on the expiry timer if it is set