首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Google Oauth2.0:

Google Oauth2.0:
EN

Stack Overflow用户
提问于 2018-05-23 17:55:07
回答 1查看 389关注 0票数 1

我使用的是带有DialogFlow实现服务器的谷歌NodeJS客户端示例:https://github.com/google/google-api-nodejs-client/tree/master/samples

生成了我的Google API Web客户端凭据,并将url重定向到https://xxxxxx.ngrok.io

然后下载JSON并重命名为samples文件夹中的oauth2.keys.json。

代码语言:javascript
复制
{
    "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,TypeError:无法读取未定义的属性“0”

DialogFlow实现服务器也在ngrok地址上运行。

更新24可能:

登录google帐户后:

代码语言:javascript
复制
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>)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-23 21:17:25

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50485222

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档