@@ -180,7 +180,7 @@ func (c *AuthStyleCache) setAuthStyle(tokenURL string, v AuthStyle) {
180
180
// as the POST body. An 'inParams' value of true means to send it in
181
181
// the POST body (along with any values in v); false means to send it
182
182
// in the Authorization header.
183
- func newTokenRequest (tokenURL , clientID , clientSecret string , v url.Values , authStyle AuthStyle ) (* http.Request , error ) {
183
+ func newTokenRequest (ctx context. Context , tokenURL , clientID , clientSecret string , v url.Values , authStyle AuthStyle ) (* http.Request , error ) {
184
184
if authStyle == AuthStyleInParams {
185
185
v = cloneURLValues (v )
186
186
if clientID != "" {
@@ -190,7 +190,7 @@ func newTokenRequest(tokenURL, clientID, clientSecret string, v url.Values, auth
190
190
v .Set ("client_secret" , clientSecret )
191
191
}
192
192
}
193
- req , err := http .NewRequest ( "POST" , tokenURL , strings .NewReader (v .Encode ()))
193
+ req , err := http .NewRequestWithContext ( ctx , "POST" , tokenURL , strings .NewReader (v .Encode ()))
194
194
if err != nil {
195
195
return nil , err
196
196
}
@@ -219,7 +219,7 @@ func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string,
219
219
authStyle = AuthStyleInHeader // the first way we'll try
220
220
}
221
221
}
222
- req , err := newTokenRequest (tokenURL , clientID , clientSecret , v , authStyle )
222
+ req , err := newTokenRequest (ctx , tokenURL , clientID , clientSecret , v , authStyle )
223
223
if err != nil {
224
224
return nil , err
225
225
}
@@ -238,7 +238,7 @@ func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string,
238
238
// they went, but maintaining it didn't scale & got annoying.
239
239
// So just try both ways.
240
240
authStyle = AuthStyleInParams // the second way we'll try
241
- req , _ = newTokenRequest (tokenURL , clientID , clientSecret , v , authStyle )
241
+ req , _ = newTokenRequest (ctx , tokenURL , clientID , clientSecret , v , authStyle )
242
242
token , err = doTokenRoundTrip (ctx , req )
243
243
}
244
244
if needsAuthStyleProbe && err == nil {
0 commit comments