@@ -180,7 +180,7 @@ func (c *AuthStyleCache) setAuthStyle(tokenURL string, v AuthStyle) {
180180// as the POST body. An 'inParams' value of true means to send it in
181181// the POST body (along with any values in v); false means to send it
182182// 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 ) {
184184 if authStyle == AuthStyleInParams {
185185 v = cloneURLValues (v )
186186 if clientID != "" {
@@ -190,7 +190,7 @@ func newTokenRequest(tokenURL, clientID, clientSecret string, v url.Values, auth
190190 v .Set ("client_secret" , clientSecret )
191191 }
192192 }
193- req , err := http .NewRequest ( "POST" , tokenURL , strings .NewReader (v .Encode ()))
193+ req , err := http .NewRequestWithContext ( ctx , "POST" , tokenURL , strings .NewReader (v .Encode ()))
194194 if err != nil {
195195 return nil , err
196196 }
@@ -219,7 +219,7 @@ func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string,
219219 authStyle = AuthStyleInHeader // the first way we'll try
220220 }
221221 }
222- req , err := newTokenRequest (tokenURL , clientID , clientSecret , v , authStyle )
222+ req , err := newTokenRequest (ctx , tokenURL , clientID , clientSecret , v , authStyle )
223223 if err != nil {
224224 return nil , err
225225 }
@@ -238,7 +238,7 @@ func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string,
238238 // they went, but maintaining it didn't scale & got annoying.
239239 // So just try both ways.
240240 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 )
242242 token , err = doTokenRoundTrip (ctx , req )
243243 }
244244 if needsAuthStyleProbe && err == nil {
0 commit comments