Skip to content

Commit 1197ebc

Browse files
authored
fix(auth): set Content-Type in userTokenProvider.exchangeToken (googleapis#12634)
1 parent 56d1157 commit 1197ebc

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

auth/credentials/impersonate/user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ func (u userTokenProvider) exchangeToken(ctx context.Context, signedJWT string)
179179
if err != nil {
180180
return nil, err
181181
}
182+
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
182183
u.logger.DebugContext(ctx, "impersonated user token exchange request", "request", internallog.HTTPRequest(req, []byte(v.Encode())))
183184
resp, body, err := internal.DoRequest(u.client, req)
184185
if err != nil {

auth/credentials/impersonate/user_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ func TestNewCredentials_user(t *testing.T) {
119119
}
120120
}
121121
if strings.Contains(req.URL.Path, "/token") {
122+
if got, want := req.Header.Get("Content-Type"), "application/x-www-form-urlencoded"; got != want {
123+
t.Errorf("got %v, want %v", got, want)
124+
}
122125
resp := exchangeTokenResponse{
123126
AccessToken: userTok,
124127
TokenType: internal.TokenTypeBearer,

0 commit comments

Comments
 (0)