Always send Bearer auth for OAuth2 connectors
Provider token_type values are not reliably valid HTTP auth schemes (Slack returns "bot" / "user", some providers send an empty string), which produces a malformed Authorization header on subsequent requests. Every OAuth2 connector in this codebase actually uses a bearer token, so we always send "Bearer". Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -583,6 +583,10 @@ type oauth2Transport struct {
|
||||
|
||||
func (t *oauth2Transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
req2 := req.Clone(req.Context())
|
||||
req2.Header.Set("Authorization", t.tokenType+" "+t.token)
|
||||
// tokenType from the provider's OAuth response is not always a valid HTTP
|
||||
// auth scheme (Slack returns "bot" / "user", some providers send an empty
|
||||
// string), so we always send "Bearer" -- the only scheme any connector in
|
||||
// this codebase actually needs.
|
||||
req2.Header.Set("Authorization", "Bearer "+t.token)
|
||||
return t.underlying.RoundTrip(req2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user