2

I built an application that uses Facebook authentication and it works as expected when running from localhost. However, after deploying the application to OpenShift and testing it with the right domain name, the server don't save the user.

Facebook settings in Development: 1

Facebook settings in Production: 2

OpenShift settings:

rhc set-env FACEBOOK_ID=id -a <appname-id>
rhc set-env FACEBOOK_SECRET=secret -a <appname-secret>

On documentation it says that I need to add this but it doesn't work: You will also need to set DOMAIN environment variable

rhc config:set DOMAIN=<appname>.rhcloud.com

I restarted the server but always the same:

rhc app-restart -a <appname>

I would appreciate any suggestions or even any thoughts on what questions I should be asking.


UPDATE 1

So I check the logs and the only diference on GET is:

OpenShift

GET /auth/facebook 302 3ms - 510b
GET /<appname>.rhcloud.com/auth/facebook/callback?code=XXXXXX 200 5ms

Localhost

GET /auth/facebook 302 10ms - 444b
GET /auth/facebook/callback?code=XXXXXXXX 302 1360ms - 58b

On OpenShift it adds the domain, any thoughts?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
ricardopereira
  • 11,118
  • 5
  • 63
  • 81
  • P.S. How can I log the server on production to get more information? – ricardopereira Aug 12 '14 at 11:14
  • Facebook requires applications to be host through HTTPS protocol... but that's weird if it worked for you in localhost without SSL – Oliboy50 Aug 12 '14 at 11:35
  • 1
    I've had it work from localhost as well (without SSL), it's possible to set that so it works. I'm interested to see if it works on openshift as well, but sadly not in the position to fiddle around right now. – Spork Aug 12 '14 at 11:46
  • 1
    What do you see in the logs on your gear? https://help.openshift.com/hc/en-us/articles/202328880 – niharvey Aug 13 '14 at 20:44

1 Answers1

2

The problem was the callbackURL of FacebookStrategy on production mode.

The right configuration is:

clientID:     process.env.FACEBOOK_ID || 'id',
clientSecret: process.env.FACEBOOK_SECRET || 'secret',
callbackURL:  '/auth/facebook/callback'
ricardopereira
  • 11,118
  • 5
  • 63
  • 81