-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: headers were incorrectly set to application/x-www-form-urlencoded #362
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -610,16 +610,14 @@ describe('.getToken()', () => { | |
}); | ||
|
||
function createGetTokenMock(code = 200, body?: {}) { | ||
return nock(GOOGLE_TOKEN_URLS[0]) | ||
return nock(GOOGLE_TOKEN_URLS[0], { | ||
reqheaders: {'Content-Type': 'application/json'}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we had
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that the docs do call out that headers are specified in this outer function, but doesn't it have to have some way to define header assertions on a per-route basis? Like it makes sense to be that these could be defined at the top level for the host, but I would expect |
||
}) | ||
.replyContentLength() | ||
.post( | ||
GOOGLE_TOKEN_URLS[1], | ||
{ | ||
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', | ||
assertion: /.?/, | ||
}, | ||
{reqheaders: {'Content-Type': 'application/x-www-form-urlencoded'}} | ||
) | ||
.post(GOOGLE_TOKEN_URLS[1], { | ||
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', | ||
assertion: /.?/, | ||
}) | ||
.reply(code, body); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried this is not correct. I'm reading this doc:
https://developers.google.com/identity/protocols/oauth2/service-account#httprest
It's pretty specific:
Do we have an end to end test checking this out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If gaxios sees an object it turns it into application/json for content-type, I'm 99% sure that we were never setting the form encoded header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I totally believe you. I'm specifically scared that POST-ing JSON happens to work on the endpoint you're using, but that it isn't fully supported.