使用React Native + Parse + Facebook处理INVALID_SESSION_TOKEN错误代码251

时间:2015-12-08 20:21:02

标签: ios facebook parse-platform login react-native

好像这里引用的解决方案:

不再有效。我尝试了这两个并通过重置秘密来重新配置我的Facebook应用程序,使用我的新应用程序凭据重新配置Parse,以及为新的模拟器环境重置xCode并且都失败了。调用以下函数时,我继续获取旧的身份验证数据:

//sign up into parse db
             Parse.FacebookUtils.logIn(authData, {
                  success: (user) => {
                    if (user.existed()) {
                      // login: nothing to do
                      console.log('User Already Logged In');
                      that.setState({loadingCurrentUser: false});
                      that.props.navigator.immediatelyResetRouteStack([{ name: 'home'}]);
                    } else {
                      // signup: update user data, e.g. email
                      console.log('getting user additional information');
                      var data = user.get('authData').facebook;
                      var api = 'https://graph.facebook.com/v2.3/'+data.id+'?fields=name,email&access_token='+data.access_token;

                      var fetchProfile = new FBSDKGraphRequest((error, result) => {
                        if (error) {
                          // TODO: error
                          this.setState({loadingCurrentUser: false});
                        } else {
                          console.log(result);
                          var name = responseData.name;
                          var email = responseData.email;

                          // FIXME: https://github.com/ParsePlatform/ParseReact/issues/45
                          var userId = {
                            className: '_User',
                            objectId: user.id
                          };

                          ParseReact.Mutation.Set(userId, {
                            username: email,
                            email: email,
                            name: name
                          }).dispatch();

                          that.setState({loadingCurrentUser: false});
                          that.props.navigator.immediatelyResetRouteStack([{ name: 'onboarding'}]);
                        }
                      }, '/me?fields=name,email');
                      // FIXME https://github.com/facebook/react-native-fbsdk/issues/20
                      // fetchProfile.start();
                      FBSDKGraphRequestManager.batchRequests([fetchProfile], function() {}, 10)
                    }
                  },
                  error: (user, error) => {
                    console.log('Error', error);
                    console.log(user.token);
                    switch (error.code) {
                      case Parse.Error.INVALID_SESSION_TOKEN:
                        Parse.User.logOut().then(() => {
                          this.onFacebookLogin(token);
                        });
                        break;
                      default:
                        // TODO: error
                    }
                    that.setState({loadingCurrentUser: false});
                    that.setState({errorMessage: error.message});
                  }
                });

我不知道该怎么办。有关错误251和最新版本的React Native(iOS)的任何帮助吗?

0 个答案:

没有答案