Skip to content

Commit 2de5423

Browse files
committed
Add Scope specifies optional requested permissions for tokenRefresher
Some OAuth providers require "scope" value with "refresh_token" grant type
1 parent d2e6202 commit 2de5423

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

oauth2.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,16 @@ func (tf *tokenRefresher) Token() (*Token, error) {
248248
return nil, errors.New("oauth2: token expired and refresh token is not set")
249249
}
250250

251-
tk, err := retrieveToken(tf.ctx, tf.conf, url.Values{
251+
v := url.Values{
252252
"grant_type": {"refresh_token"},
253253
"refresh_token": {tf.refreshToken},
254-
})
254+
}
255+
256+
if len(tf.conf.Scopes) > 0 {
257+
v.Set("scope", strings.Join(tf.conf.Scopes, " "))
258+
}
259+
260+
tk, err := retrieveToken(tf.ctx, tf.conf, v)
255261

256262
if err != nil {
257263
return nil, err

0 commit comments

Comments
 (0)