gpt4 book ai didi

node.js - 谷歌Oauth2.0 :

转载 作者:太空宇宙 更新时间:2023-11-04 00:09:38 24 4
gpt4 key购买 nike

我正在将 Google NodeJS 客户端示例与 DialogFlow 履行服务器结合使用:https://github.com/google/google-api-nodejs-client/tree/master/samples .

生成了我的 Google API Web 客户端凭据,并将我的重定向网址设置为 https://xxxxxx.ngrok.io

然后下载 JSON 并在示例文件夹中重命名为 oauth2.keys.json。

{
"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"]
}
}

当我运行 node oauth2.js 时,我会被定向到一个网站,并提示我登录 Google 帐户。我有以下错误:

keys.redirect_uris[0] , TypeError: Cannot read property '0' of undefined

DialogFlow 履行服务器也在 ngrok 地址运行。

5 月 24 日更新:

登录 Google 帐户后:

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>)

最佳答案

如果您确实尝试运行 oauth2.js,请确保oauth2.keys.json 文件与oauth2.js 文件位于同一目录中。如果您只是使用 oauth2.js 作为生成自己的 token 的示例,则可以修改该文件以从对您有意义的任何位置读取 key 。

关于node.js - 谷歌Oauth2.0 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50485222/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com