Facebook Oauth on Cloud9

Facebook requires the website URL where the website is located to check Oauth requests. Facebook also requires valid callback URLs , basically a list of URLs that Facebook can safely transfer to Oauth tokens.

Here is the difference in my on-premises environment versus my cloud9 environment regarding the installation of Oauth Facebook:

Localhost

  • Website URL: http://localhost:3000
  • Callback URL: http://localhost:3000/auth/facebook/callback

Cloud9

  • Website URL: http://myapp-cireficc.c9.io/
  • Callback URL: http://myapp-cireficc.c9.io/auth/facebook/callback

My localhost setup is working fine. However, when I run my application on cloud9, I get the following error from Facebook:

The specified URL is not allowed by the application configuration: one or more of the specified URLs is not allowed by the application settings. It must match the website URL or canvas URL, or the domain must be a subdomain of one of the application domains.

This means that one of these two options is incorrect ... and after a little debugging, it looks like Facebook is trying to access this callback url:

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

And after decoding this code into more readable characters, we have:

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

It seems that this random : 80 is being added to the callback url, which makes me think that when the Oauth request is sent, it is added, and Facebook just dutifully attaches it to the response, which is now incorrect . Since adding : 80 , the expected and actual callbacks are different:

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

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

It seems to me that Cloud9 adds when it sends a request (perhaps because of how their domain names are configured?). What can I do to get Facebook Oauth to work with cloud9?

Note : Cloud9 env.PORT is 8080 , and env.IP is 0.0.0.0 . This seems to be happening at : 80 in the callback, but I don't know how to get around this problem.

Interestingly, I have an intermediate environment created on Heroku, and Heroku does not have this problem. I can easily access Oauth Facebook there using http://myapp-staging.herokuapp.com and the correct callback url.

+5
source share
2 answers

Had the same problem: adding a port (: 80) to the cloud url9, and then adding it to the Primary OAuth URI redirects it for me.

+1
source

@ AnthonyGrove's answer did not help me.

However, adding a port (: 8080) to the cloud9 url and then adding it to the Valid OAuth redirect URI fixed it for me.

From docs : Please note that 8080, 8081, and 8082 are the only available ports on a hosted Cloud9 workspace.

+1
source

Source: https://habr.com/ru/post/1233732/


All Articles