Hi there,
anyone can share a snippet on how to use Meteor.loginWithFacebook
when a single app runs on multiple domains?
The CHANGELOG of the facebook-oauth
package hints that it’s possible but it’s not very helpful:
- Supports
params
andabsoluteUrlOptions
as options and pass along toOAuth._redirectUri
, this is important to authenticate using Facebook using different domains in the same server.
- Supports a new way to call the token from Facebook using a URL that is different from the ROOT_URL. With
overrideRootUrlFromStateRedirectUrl
astrue
in the settings (packages.facebook-oauth.overrideRootUrlFromStateRedirectUrl
) we are going to use the redirect URL provided in the initial call. So the redirect URL will be used again in the server to get the token, this information will come from the state. This is important to authenticate using Facebook using different domains in the same server.
If I set overrideRootUrlFromStateRedirectUrl
to true, oauth_server.js
throws an error. It seems the ROOT_URL
is still used for the oauth flow instead of the URL extracted from redirectUrl
.
(oauth_server.js:405) Error in OAuth Server: redirectUrl (https://XXX.eu.ngrok.io/_oauth/facebook) is not on the same host as the app (http://localhost:3000/)
If I pass absoluteUrlOptions: { rootUrl: `${window.location.origin}/` }
to Meteor.loginWithFacebook
, I get the same result.