Cloud9 上的 Facebook Oauth

Facebook Oauth on Cloud9

Facebook 需要 website URL,其中托管网站以验证 Oauth 请求。 Facebook 还需要有效的 callback URLs,基本上是 Facebook 可以安全地将 Oauth 令牌传递到的 URL 列表。

以下是我的本地环境与我的 cloud9 环境的区别,关于 Facebook Oauth 设置:

本地主机:

Cloud9:

我的本地主机设置工作正常。但是,当我 运行 我在 cloud9 上的应用程序时,我从 Facebook 收到以下错误:

Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

这暗示这两个参数之一是错误的...经过一些调试,Facebook 似乎正在尝试访问 this 回调URL:

redirect_uri=http%3A%2F%2Fmyapp-cireficc.c9.io%3A80%2Fauth%2Ffacebook%2Fcallback

将其解码为更易读的字符后,我们有:

http://myapp-cireficc.c9.io:80/auth/facebook/callback

似乎这个随机 :80 被添加到回调 URL,这让我觉得当Oauth 请求被发送出去,它被附加,Facebook 只是尽职尽责地将它附加到响应回调,现在 不正确 。由于正在添加 :80,因此 expectedactual 回调不同:

预期http://myapp-cireficc.c9.io/auth/facebook/callback

实际: http://myapp-cireficc.c9.io:80/auth/facebook/callback

在我看来,这似乎是 cloud9 在发出请求时添加的内容(可能是由于其域名的设置方式?)。我该怎么做才能让 Facebook Oauth 在 cloud9 上运行?

注意:Cloud9的env.PORT8080env.IP0.0.0.0。这似乎是回调中 :80 的来源,但我不知道如何解决这个问题。

有趣的是,我在 Heroku 上设置了 staging 环境,而 Heroku 没有这个问题。我可以使用 http://myapp-staging.herokuapp.com 和正确的回调 URL.

轻松访问那里的 Facebook Oauth

有同样的问题:将端口 (:80) 添加到 cloud9 url,然后将其添加到有效的 OAuth 重定向 URI 为我修复了它。

@AnthonyGrove 的回答对我不起作用。

但是,将端口 (:8080) 添加到 cloud9 url,然后将其添加到有效的 OAuth 重定向 URI 为我修复了它。

来自docsPlease note that 8080, 8081, and 8082 are the only available ports on a hosted Cloud9 workspace.