roughike / flutter_facebook_login

A Flutter plugin for allowing users to authenticate with native Android & iOS Facebook login SDKs.
BSD 2-Clause "Simplified" License
405 stars 331 forks source link

Facebook Login ERROR_INVALID_CREDENTIAL #238

Open tsapucaia opened 4 years ago

tsapucaia commented 4 years ago

I'm trying to log in using an AuthCredential generated by Facebook, but it doesn't work, I already tested the Facebook API and everything is fine. I was analyzing all the generated accessToken, it looks different from the one generated by the google login

error: Exception has occurred. PlatformException (PlatformException(ERROR_INVALID_CREDENTIAL, The supplied auth credential is malformed or has expired. [ Unsuccessful debug_token response from Facebook: {"error":{"message":"Invalid OAuth access token signature.","type":"OAuthException","code":190,"fbtrace_id":"A4fHA7EI2XEClpIQIcbyXvt"}} ], null))

token: EAAIp82wZBI5MBADZBlh4lQ3oRsKnOwPD0ZAidYnZCBYS083LUU2AnHKkadxfXTa3N13qlA9YxwPMMZB6pfv3CB7ZAdCZBRRAROIQpaJ5IRQ1YhEXND38my8bB3hUdrf


Future<FirebaseUser> signInWithFacebook() async {
    final facebookLogin = FacebookLogin();
    final result = await facebookLogin.logIn(['email', 'public_profile']);
    if (result.status == FacebookLoginStatus.loggedIn) {
      final accessToken = result.accessToken;
      final token = accessToken.token;
      final credential = FacebookAuthProvider.getCredential(accessToken: token);
      await _firebaseAuth.signInWithCredential(credential);
      final graphResponse = await dio.get(
          'https://graph.facebook.com/v2.12/me?fields=name,first_name,last_name,email&access_token=$token');

      return _firebaseAuth.currentUser();
    }
  }
redbrickred commented 4 years ago

I suspect the expires timestamp is not getting set. I see this on the Android platform, but not IOS. (Token Expires: 1969.12.31 11:59:59 PM)

        final accessToken = await _facebookLogin.currentAccessToken;

        if (!accessToken.isValid()) {
          DateFormat dateFormat = DateFormat('yyyy.MM.dd hh:mm:ss aaa');
          logger.e(
              'Facebook accessToken appears invalid.  Now: ${dateFormat.format(DateTime.now())}  Expires: ${dateFormat.format(accessToken.expires)}');
        }
abdulwahid24 commented 4 years ago

Facing the issue.

( 2132): Inactivity, disconnecting from the service
I/BiChannelGoogleApi( 2132): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@25a6e6
I/flutter ( 2132): PlatformException(ERROR_INVALID_CREDENTIAL, The supplied auth credential is malformed or has expired. [ Unsuccessful debug_token response from Facebook: {"error":{"message":"(#100) You must provide an app access token or a user access token that is an owner or developer of the app","type":"OAuthException","code":100,"fbtrace_id":"AWTXhVaxr_YYaZEhBgXxdzh"}} ], null)

Not sure why its calling getGoogleApiMethod() while authorizing Facebook.