ParseReact
ParseReact copied to clipboard
login parse with FacebookUtils invalid date in android
I want to use facebook login to parse in android device.
when trying login parse with facebook on ios, the code is below:
onFacebookLogin: function(token) {
if (!token)
return;
//console.log(token);
var authData = {
id: token.userID,
access_token: token.tokenString,
// expiration_date: token.expirationDate()
expiration_date: new Date(token._expirationDate)
};
Parse.FacebookUtils.logIn(authData, {
success: (user) => {
if (user.existed()) {
// login
} else {
// signup
},
error: (user, error) => {
switch (error.code) {
case Parse.Error.INVALID_SESSION_TOKEN:
Parse.User.logOut().then(() => {
this.onFacebookLogin(token);
});
break;
default:
// TODO: error
}
this.setState({loadingCurrentUser: false});
}
});
},
when i try the same way on android, it failed.
onLogin={function(data){
var credentials = data;
let authData = {
id: credentials.profile.id,
access_token: credentials.token,
expiration_date: credentials.expiration
};
Parse.FacebookUtils.logIn(authData, {
success: function(user) {
if (!user.existed()) {
alert("User signed up and logged in through Facebook!");
} else {
alert("User logged in through Facebook!");
}
},
error: function(user, error) {
console.log(error);
alert("User cancelled the Facebook login or did not fully authorize.");
}
});
}}
and this is the console in error function: I/ReactNativeJS: { code: 107, message: 'Invalid date' }
I include this modules
var Parse = require('parse/react-native');
var ParseReact = require('parse-react/react-native');
var NativeModules = require('react-native');
var FBLogin = require('react-native-facebook-login');
var FBLoginManager = NativeModules.FBLoginManager;