Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

login parse with FacebookUtils invalid date in android #167

Open
Ray0427 opened this issue Feb 15, 2016 · 0 comments
Open

login parse with FacebookUtils invalid date in android #167

Ray0427 opened this issue Feb 15, 2016 · 0 comments

Comments

@Ray0427
Copy link

Ray0427 commented Feb 15, 2016

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;
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant