UPDATE: When I deploy the app to meteor.com I do not get any of the same issues, so the problem is definitely related to the development environment and I suspect somehting to do with ROOT_URL and the way redirects are handled.
I am running Meteor on Nitrous.io.
I have installed the accounts-facebook package and have added the following to the server folder:
ServiceConfiguration.configurations.remove({
service: "facebook"
});
ServiceConfiguration.configurations.insert({
service: "facebook",
appId: '31058319242*****',
secret: '4f6c8a9b5aab235111e97*********',
site_url: 'http://accounts-*****.apse2.nitrousbox.com/'
});
I have also changed the root url of my application at startup:
Meteor.startup(function () {
Meteor.absoluteUrl.defaultOptions.rootUrl = "http://accounts-*****.apse2.nitrousbox.com/"
});
I have included the exact same url to my apps 'Basic' settings:
and 'Advanced' settings:
[obviously, the ***** is actually a string identifying my Nitrous 'box' - I have redacted it here]
However, when I try to authorise using facebook I get the following error:
Exception while invoking method 'login' Error: Failed to complete OAuth handshake with Facebook. failed [400]
{
"error":
{
"message":"Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type":"OAuthException",
"code":191
}
}
I have tried a number of different variations on these settings, but without success.
Has anyone else come across this issue? Help appreciated.
The issue is ROOT_URL isn't set to box's URL. You will notice terminal output still says => App running at: http://localhost:3000/
when you start the app with meteor
command.
Meteor.absoluteUrl
is only a utility function (https://github.com/meteor/meteor/issues/858). You need to override the ROOT_URL
environment variable when starting the app.
Try starting the app with ROOT_URL=http://accounts-*****.apse2.nitrousbox.com/ meteor
. Then, Facebook auth process should work correctly.
laktek's answer above is correct. I am adding this image to illustrate how the solution is achieved because it was not immediately obvious to me.
Omit the Meteor.absoluteUrl function and instead start meteor within the nitrous console as follows:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With