Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deviceauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func retrieveDeviceAuth(ctx context.Context, c *Config, v url.Values) (*DeviceAu
return nil, errors.New("endpoint missing DeviceAuthURL")
}

req, err := http.NewRequest("POST", c.Endpoint.DeviceAuthURL, strings.NewReader(v.Encode()))
req, err := http.NewRequestWithContext(ctx, "POST", c.Endpoint.DeviceAuthURL, strings.NewReader(v.Encode()))
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions internal/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (c *AuthStyleCache) setAuthStyle(tokenURL string, v AuthStyle) {
// as the POST body. An 'inParams' value of true means to send it in
// the POST body (along with any values in v); false means to send it
// in the Authorization header.
func newTokenRequest(tokenURL, clientID, clientSecret string, v url.Values, authStyle AuthStyle) (*http.Request, error) {
func newTokenRequest(ctx context.Context, tokenURL, clientID, clientSecret string, v url.Values, authStyle AuthStyle) (*http.Request, error) {
if authStyle == AuthStyleInParams {
v = cloneURLValues(v)
if clientID != "" {
Expand All @@ -190,7 +190,7 @@ func newTokenRequest(tokenURL, clientID, clientSecret string, v url.Values, auth
v.Set("client_secret", clientSecret)
}
}
req, err := http.NewRequest("POST", tokenURL, strings.NewReader(v.Encode()))
req, err := http.NewRequestWithContext(ctx, "POST", tokenURL, strings.NewReader(v.Encode()))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -219,7 +219,7 @@ func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string,
authStyle = AuthStyleInHeader // the first way we'll try
}
}
req, err := newTokenRequest(tokenURL, clientID, clientSecret, v, authStyle)
req, err := newTokenRequest(ctx, tokenURL, clientID, clientSecret, v, authStyle)
if err != nil {
return nil, err
}
Expand All @@ -238,7 +238,7 @@ func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string,
// they went, but maintaining it didn't scale & got annoying.
// So just try both ways.
authStyle = AuthStyleInParams // the second way we'll try
req, _ = newTokenRequest(tokenURL, clientID, clientSecret, v, authStyle)
req, _ = newTokenRequest(ctx, tokenURL, clientID, clientSecret, v, authStyle)
token, err = doTokenRoundTrip(ctx, req)
}
if needsAuthStyleProbe && err == nil {
Expand Down