Continuing the discussion from Facebook login + Parse :
Currently there is no support for handling the facebook login by Parse via the InAppBrowser i guess.
I just debugged a bit and saw that the origin url in the request (which is handled by the Parse SDK / FB SDK) is something like file://{HASH}
(example: file://f3b7695e8
) which is correct because the origin of the request is a local embedded file from cordova. You can’t add a file://
path to your facebook app, so there is no way to get around it.
Here is the alternative you can go with:
Use the OpenFB library by Christophe Coenraets to handle the facebook login by your own. His library builds up the facebook login url itself . This enables you to add a callbackUrl to your app settings.
This way you can signup your users with facebook data through the Parse.User.signUp
method and enforce them to set a password.
Parse.FacebookUtils.login
openFB.login
@darrenahunter Do you have any idea of getting the parse-angular-demo on phonegap / cordova working ?
Can anybody confirm the same behaviors ?
Further reading
I can use the OpenFb library (see above) to connect an FB user to a current Parse.User
(i.e. Parse.User.current()
) or to a new Parse.User
. It works fine.
But how do you handle the case when existing user tries to sign-in using FB Connect? I can do an FB login and then call Parse.Query
to find the matching Parse.User
record. But I can’t actually do a Parse.User.logIn()
because I don’t have the actual password.
Is there a workaround here? Or do you just re-direct the user to sign-in with their Parse username/password?
You can use the Parse REST API to login a Parse.User from the Facebook id & accessToken. This method doesn’t seem to be available in the Parse JDK
see: https://parse.com/docs/rest/guide#users-signing-up-and-logging-in
return $cordovaFacebook.login(["public_profile", "email", "user_friends"])
.then(function (success) {
// save access_token
$localStorage.accessToken = success.authResponse.accessToken;
$localStorage.userID = success.authResponse.userID;
$localStorage.expiresIn = success.authResponse.expiresIn;
console.log("Login Success" + JSON.stringify(success));
var expDate = new Date(new Date().getTime() + $localStorage.expiresIn * 1000).toISOString();
return Parse.FacebookUtils.logIn({
id: $localStorage.userID,
access_token: $localStorage.accessToken,
expiration_date: expDate
});
}).then(function (_parseResult) {
$localStorage.parseData = _parseResult;
).function(_error) {
console.log(JSON.stringify(_error));
};
})
Basically login the normal way through Facebook and pass the authData
through to Parse.com
See more details here - http://www.clearlyinnovative.com/ionic-framework-facebook-login-with-parse/
1 Like