【问题标题】:Meteor accounts-google internal server error, works on local but not on EC2Meteor 帐户-google 内部服务器错误,适用于本地但不适用于 EC2
【发布时间】:2016-03-15 03:00:25
【问题描述】:

您好 Stackoverflow 社区,我在使用 Meteor 的 google 登录时遇到问题。

登录流程在 localhost 中运行良好,但在部署中却不行。

我在 Meteor 的控制台上收到以下错误:

Exception while invoking method 'login' Error: Failed to complete OAuth handshake with Google. failed [400] {   "error" : "redirect_uri_mismatch" }
at getTokens (packages/google/google_server.js:59:1)
at Object.ServiceConfiguration.configurations.findOne.service [as handleOauthRequest] (packages/google/google_server.js:10:1)
at OAuth._requestHandlers.(anonymous function) (packages/oauth2/oauth2_server.js:8:1)
at middleware (packages/oauth/oauth_server.js:173:1)
at packages/oauth/oauth_server.js:146:1

这是我当前的故障排除清单:

1.- 使用 loginStyle 'popup' 更正 db.meteor_accounts_loginServiceConfiguration 上的客户端 ID 和客户端密码

2.- 当弹出窗口打开时,redirect_uri 设置为正确的端点 (http://example.com/_oauth/google)。

3.- 在谷歌控制台上的应用重定向上授权的重定向 uri

我的观察之一是,如果将 loginStyle 更改为重定向而不是弹出窗口,在 google oauth 重定向到我的 redirect_uri 后,我的 redirect_uri 再次重定向到 localhost 而不是经典的 */_oauth/google 窗口(登录完成。点击这里关闭此窗口。)

编辑 出现的另一个错误是:

Error in OAuth Server: redirectUrl (http://example.com/users) is not on the same host as the app (http://localhost:80/)

所以应用程序拒绝了redirectUrl(该域对我的亚马逊ec2实例的弹性IP有一个A记录),我在端口80上运行仅用于测试目的

【问题讨论】:

    标签: meteor oauth google-oauth meteor-accounts


    【解决方案1】:

    检查环境变量 $ROOT_URL 的设置。如果设置不正确,这可能会影响预期的重定向 URL。

    我使用 google oauth 弹出窗口并在我的授权重定向 URI 中使用此字符串:

    http://example.org
    http://example.org/_oauth/google?close
    

    编辑:

    即使我将 ROOT_URL 设置为环境变量,不知何故 Meteor 也没有使用我的 ROOT_URL。

    解决方案是将流星运行为:

    $ ROOT_URL='https://example.org' meteor
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-24
      • 1970-01-01
      • 2022-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-11
      相关资源
      最近更新 更多