From 67b0cc3077860a1583bcf18ce50aeff58bbb5496 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Thu, 17 Dec 2020 17:39:22 -0800 Subject: [PATCH] fix: move accessToken to headers instead of parameter (#1108) --- src/auth/oauth2client.ts | 2 +- test/test.oauth2.ts | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/auth/oauth2client.ts b/src/auth/oauth2client.ts index 046863f5..47809098 100644 --- a/src/auth/oauth2client.ts +++ b/src/auth/oauth2client.ts @@ -1018,9 +1018,9 @@ export class OAuth2Client extends AuthClient { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', + Authorization: `Bearer ${accessToken}`, }, url: OAuth2Client.GOOGLE_TOKEN_INFO_URL, - data: querystring.stringify({access_token: accessToken}), }); const info = Object.assign( { diff --git a/test/test.oauth2.ts b/test/test.oauth2.ts index e53fbcaa..62fd416a 100644 --- a/test/test.oauth2.ts +++ b/test/test.oauth2.ts @@ -1322,18 +1322,13 @@ describe('oauth2', () => { expires_in: 1234, }; - const scope = nock(baseUrl) - .post( - '/tokeninfo', - qs.stringify({ - access_token: accessToken, - }), - { - reqheaders: { - 'content-type': 'application/x-www-form-urlencoded', - }, - } - ) + const scope = nock(baseUrl, { + reqheaders: { + 'content-type': 'application/x-www-form-urlencoded', + authorization: `Bearer ${accessToken}`, + }, + }) + .post('/tokeninfo', () => true) .reply(200, tokenInfo); const info = await client.getTokenInfo(accessToken);