Skip to content

Commit 24b5181

Browse files
author
Gregg Luskin
authoredSep 9, 2018
Update getToken from functinosOauthClient
The sample code shows to set the results of `getToken` directly to the variable tokens however tokens is now a property of the response so you need to store the tokens object from within the response as google states here: https://github.com/google/google-api-nodejs-client: ``` const {tokens} = await oauth2Client.getToken(code) oauth2Client.setCredentials(tokens); ```
1 parent 4d3e15b commit 24b5181

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎google-sheet-sync/functions/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ exports.oauthcallback = functions.https.onRequest(async (req, res) => {
6565
res.set('Cache-Control', 'private, max-age=0, s-maxage=0');
6666
const code = req.query.code;
6767
try {
68-
const tokens = await functionsOauthClient.getToken(code);
68+
const {tokens} = await functionsOauthClient.getToken(code);
6969
// Now tokens contains an access_token and an optional refresh_token. Save them.
7070
await admin.database().ref(DB_TOKEN_PATH).set(tokens);
7171
return res.status(200).send('App successfully configured with new Credentials. '

0 commit comments

Comments
 (0)
Please sign in to comment.