Reputation: 73
I'm using the Google NodeJS client sample with DialogFlow fulfilment server: https://github.com/google/google-api-nodejs-client/tree/master/samples.
Generated my Google API Web Client credential, with my redirect url to https://xxxxxx.ngrok.io
Then downloaded JSON and renamed to oauth2.keys.json in samples folder.
{
"web": {
"client_id": "XXXXX.apps.googleusercontent.com",
"project_id": "XXXX",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "XXXX",
"redirect_uris": ["https://XXXX.ngrok.io"]
}
}
When I run node oauth2.js, I'm directed to a website and am prompted to login to a google account. I have the following error :
keys.redirect_uris[0] , TypeError: Cannot read property '0' of undefined
The DialogFlow fulfilment server is also running at the ngrok address.
UPDATE 24 may:
after logging into google account:
Headers {
"host": "xxxx.ngrok.io",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/xx.x.xxxx.xxx Safari/537.36",
"accept": "image/webp,image/apng,image/*,*/*;q=0.8",
"referer": "https://xxxxxxx.ngrok.io/?code=xxxxxxxxxxxxxxxxxxxxxxxxx",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
"x-forwarded-proto": "https",
"x-forwarded-for": "xxx.xx.xx.xxx"
}
TypeError: Cannot read property 'payload' of undefined
at getRequest (/Users/xxxxx/Desktop/facts/functions/node_modules/actions-on-google/dist/service/dialogflow/conv.js:30:45)
at new DialogflowConversation (/Users/xxxxx/Desktop/facts/functions/node_modules/actions-on-google/dist/service/dialogflow/conv.js:37:22)
at Function.<anonymous> (/Users/xxxxxx/Desktop/facts/functions/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:113:24)
at Generator.next (<anonymous>)
at /Users/xxxxxxx/Desktop/facts/functions/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:22:71
at new Promise (<anonymous>)
at __awaiter (/Users/xxxxx/Desktop/facts/functions/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:18:12)
at Function.handler (/Users/xxxxx/Desktop/facts/functions/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:84:16)
at Object.<anonymous> (/Users/xxxxxx/Desktop/facts/functions/node_modules/actions-on-google/dist/assistant.js:55:32)
at Generator.next (<anonymous>)
Upvotes: 1
Views: 473
Reputation: 50701
If you're actually trying to run oauth2.js, make sure the oauth2.keys.json
file is in the same directory as the oauth2.js file. If you're just using oauth2.js as an example for generating your own tokens, you can modify the file to read the keys from any location that makes sense for you.
Upvotes: 1