@@ -246,10 +246,11 @@ func (c *Config) Client(ctx context.Context, t *Token) *http.Client {
246
246
// automatically refreshing it as necessary using the provided context.
247
247
//
248
248
// 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 {
250
250
tkr := & tokenRefresher {
251
251
ctx : ctx ,
252
252
conf : c ,
253
+ opts : opts ,
253
254
}
254
255
if t != nil {
255
256
tkr .refreshToken = t .RefreshToken
@@ -266,6 +267,7 @@ type tokenRefresher struct {
266
267
ctx context.Context // used to get HTTP requests
267
268
conf * Config
268
269
refreshToken string
270
+ opts []AuthCodeOption
269
271
}
270
272
271
273
// WARNING: Token is not safe for concurrent access, as it
@@ -277,10 +279,15 @@ func (tf *tokenRefresher) Token() (*Token, error) {
277
279
return nil , errors .New ("oauth2: token expired and refresh token is not set" )
278
280
}
279
281
280
- tk , err := retrieveToken ( tf . ctx , tf . conf , url.Values {
282
+ v := url.Values {
281
283
"grant_type" : {"refresh_token" },
282
284
"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 )
284
291
285
292
if err != nil {
286
293
return nil , err
0 commit comments