0

我已将 Facebook 登录添加到我的颤振项目中,并成功登录,但问题是,用户无法进入应用程序的主屏幕并停留在登录屏幕上。它响应为 Http 状态错误 [500]

下面是 Facebook 登录的代码:

void doFacebookSignIn() async{

    print("FaceBook Clicked");

try {
      final result =
      await FacebookAuth.i.login(permissions: ['email']);
      if (result.status == LoginStatus.success) {
        final userData = await FacebookAuth.i.getUserData();
        print(userData);
        hitFacebookApi(result.accessToken.token);
        await FacebookAuth.i.logOut();
        if (result.status == LoginStatus.cancelled) {
          ToastUtils.showCustomToast(context, "cancelled", Colors.white , MyColors.primaryColor);
        }
        if (result.status == LoginStatus.failed) {
          ToastUtils.showCustomToast(context, result.message, Colors.white , MyColors.primaryColor);
        }
      }
    } catch (error) {
      print(error);
    }
 }

进入主屏幕的代码:

void hitFacebookApi(String token) {
    CommonApis().logInWithFB(
        {"token": "$token"}, CommonUtils.getLanguage(context) == "english")
        .then((value) async{
      if (value is Map) {
        String  fullToken = "Bearer ${value['token']}";
        ApiUtils.headerWithToken.update("Authorization",(value)=> fullToken);
        await userData.save(fullToken, "client");
        await userService.getProfile();
        Navigator.pushAndRemoveUntil(context,PageTransition(type: PageTransitionType.fade, child:  ClientMain()), (Route<dynamic> route) => false);
      } else {
        ToastUtils.showCustomToast(
            context, value, Colors.white, MyColors.primaryColor);
        print("the cause "+value);
      }
    });
  }
4

0 回答 0