Skip to content

Commit 7bc4a85

Browse files
committed
Support for rfc 7523 in refresh token
1 parent 5fd4241 commit 7bc4a85

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Diff for: oauth2.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,11 @@ func (c *Config) Client(ctx context.Context, t *Token) *http.Client {
246246
// automatically refreshing it as necessary using the provided context.
247247
//
248248
// Most users will use Config.Client instead.
249-
func (c *Config) TokenSource(ctx context.Context, t *Token) TokenSource {
249+
func (c *Config) TokenSource(ctx context.Context, t *Token, opts ...AuthCodeOption) TokenSource {
250250
tkr := &tokenRefresher{
251251
ctx: ctx,
252252
conf: c,
253+
opts: opts,
253254
}
254255
if t != nil {
255256
tkr.refreshToken = t.RefreshToken
@@ -266,6 +267,7 @@ type tokenRefresher struct {
266267
ctx context.Context // used to get HTTP requests
267268
conf *Config
268269
refreshToken string
270+
opts []AuthCodeOption
269271
}
270272

271273
// WARNING: Token is not safe for concurrent access, as it
@@ -277,10 +279,15 @@ func (tf *tokenRefresher) Token() (*Token, error) {
277279
return nil, errors.New("oauth2: token expired and refresh token is not set")
278280
}
279281

280-
tk, err := retrieveToken(tf.ctx, tf.conf, url.Values{
282+
v := url.Values{
281283
"grant_type": {"refresh_token"},
282284
"refresh_token": {tf.refreshToken},
283-
})
285+
}
286+
for _, opt := range tf.opts {
287+
opt.setValue(v)
288+
}
289+
290+
tk, err := retrieveToken(tf.ctx, tf.conf, v)
284291

285292
if err != nil {
286293
return nil, err

0 commit comments

Comments
 (0)