I'm one of the many users migrating off of Parse and onto Heroku (w/ MongoLab sandbox), using https://parse.com/docs/server/guide as a guide.
Things were going fine with the migration (objects can be created / retrieved via REST commands on the remote repo) until I tried using (iOS) Facebook login.
The method:
[PFFacebookUtils logInInBackgroundWithReadPermissions: ... ]
which had been working when Parse hosted, now returns the following error:
[Error]: Facebook auth is invalid for this user. (Code: 101, Version: 1.12.0)
Note: the only change to my (previously working) iOS code is to point the Parse server to my new, manually-hosted repo, as shown below:
let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
ParseMutableClientConfiguration.applicationId = "<*APP ID*>"
ParseMutableClientConfiguration.clientKey = "<*CLIENT KEY*>"
ParseMutableClientConfiguration.server = "https://<*HEROKU APP ID*>.herokuapp.com/parse"
})
Parse.initializeWithConfiguration(parseConfiguration)
& the only modification to the open source Parse Server code (https://github.com/ParsePlatform/parse-server-example) is substituting the configuration to match my Parse / mongo identification:
var api = new ParseServer({
databaseURI: 'mongodb://<*UNIUQUE ID*>' || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: '<*PARSE APP ID*>',
masterKey: '<*PARSE MASTER KEY*>'
});
you need to add the key facebookAppIds which contains an array of valid facebook app ids, this is mentioned here in the docs.
alternatively, add the FACEBOOK_APP_ID key as referenced [here] (https://github.com/ParsePlatform/parse-server/issues/82)
I don't know if you already had or tried this already but I was in a very similar situation as you and what fixed it for me was this:
In AppDelegate.swift, the ParseClientConfiguration
must be initialized BEFORE the Parse Facebook Utils initialization in didFinishLaunchingWithOptions
:
...
// *** Initialize Parse. ***
let config = ParseClientConfiguration(block: {
(ParseMutableClientConfiguration) -> Void in
ParseMutableClientConfiguration.applicationId = appKey;
ParseMutableClientConfiguration.clientKey = clientKey;
ParseMutableClientConfiguration.server = serverURL;
});
Parse.initializeWithConfiguration(config);
// *NOTE: Putting the following line after after Parse.initializeWithConfiguration(config) fixed the issue
// After this change, the user is no longer nil and does not print "Uh oh. The user cancelled the Facebook login.". Instead, it executes the `if let user = user` block
PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
...
Hope this helps at least somebody!
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