Skip to content

Commit 68d6d4e

Browse files
committed
Add Scope specifies optional requested permissions for tokenRefresher
Some OAuth providers require "scope" value with "refresh_token" grant type
1 parent 5d25da1 commit 68d6d4e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

oauth2.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,16 @@ func (tf *tokenRefresher) Token() (*Token, error) {
267267
return nil, errors.New("oauth2: token expired and refresh token is not set")
268268
}
269269

270-
tk, err := retrieveToken(tf.ctx, tf.conf, url.Values{
270+
v := url.Values{
271271
"grant_type": {"refresh_token"},
272272
"refresh_token": {tf.refreshToken},
273-
})
273+
}
274+
275+
if len(tf.conf.Scopes) > 0 {
276+
v.Set("scope", strings.Join(tf.conf.Scopes, " "))
277+
}
278+
279+
tk, err := retrieveToken(tf.ctx, tf.conf, v)
274280

275281
if err != nil {
276282
return nil, err

0 commit comments

Comments
 (0)