diff options
author | eeng5 <eleanor.eng5@gmail.com> | 2019-11-19 17:49:37 -0500 |
---|---|---|
committer | eeng5 <eleanor.eng5@gmail.com> | 2019-11-19 17:49:37 -0500 |
commit | 7347f1eb7320e5e95f87c64b3222e4b4c1593be5 (patch) | |
tree | 180b80e3f32cb8d9499d1f1568cdee593abf799c /src/server/apis/google/GoogleApiServerUtils.ts | |
parent | f194abe2a54158bb041e1e0e7cfa6e22c669629f (diff) | |
parent | 8b6f70cd0ddac6d2669c3b0624d59a866737497c (diff) |
Merge branch 'server_refactor' of https://github.com/browngraphicslab/Dash-Web into server_refactor
Diffstat (limited to 'src/server/apis/google/GoogleApiServerUtils.ts')
-rw-r--r-- | src/server/apis/google/GoogleApiServerUtils.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/server/apis/google/GoogleApiServerUtils.ts b/src/server/apis/google/GoogleApiServerUtils.ts index b3657ee43..b0f3ba993 100644 --- a/src/server/apis/google/GoogleApiServerUtils.ts +++ b/src/server/apis/google/GoogleApiServerUtils.ts @@ -48,7 +48,7 @@ export namespace GoogleApiServerUtils { * allow us to build OAuth2 clients with Dash's * application specific credentials. */ - let installed: OAuth2ClientOptions; + let oAuthOptions: OAuth2ClientOptions; /** * This is a global authorization client that is never @@ -69,7 +69,7 @@ export namespace GoogleApiServerUtils { export function processProjectCredentials(): void { const { client_secret, client_id, redirect_uris } = GoogleCredentialsLoader.ProjectCredentials; // initialize the global authorization client - installed = { + oAuthOptions = { clientId: client_id, clientSecret: client_secret, redirectUri: redirect_uris[0] @@ -201,7 +201,7 @@ export namespace GoogleApiServerUtils { * @returns the newly created, potentially certified, OAuth2 client instance */ function generateClient(credentials?: Credentials): OAuth2Client { - const client = new google.auth.OAuth2(installed); + const client = new google.auth.OAuth2(oAuthOptions); credentials && client.setCredentials(credentials); return client; } @@ -341,10 +341,12 @@ export namespace GoogleApiServerUtils { */ async function refreshAccessToken(credentials: Credentials, userId: string): Promise<Credentials> { let headerParameters = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }; + const { client_id, client_secret } = GoogleCredentialsLoader.ProjectCredentials; let url = `https://oauth2.googleapis.com/token?${qs.stringify({ refreshToken: credentials.refresh_token, - grant_type: "refresh_token", - ...installed + client_id, + client_secret, + grant_type: "refresh_token" })}`; const { access_token, expires_in } = await new Promise<any>(async resolve => { const response = await request.post(url, headerParameters); |