Code Monkey home page Code Monkey logo

Comments (13)

owllyi avatar owllyi commented on May 26, 2024 1

same issue in my unity game.
Unity: 2021.3.37f1
Firebase SDK: 10.2.0
Facebook SDK: 17.0.0

Error Message:
SignInWithCredentialAsync encountered an error: System.AggregateException: One or more errors occurred. (One or more errors occurred. (Bad access token: {"code":190,"message":"Malformed access token"}))

Firebase.FirebaseException: Bad access token: {"code":190,"message":"Invalid OAuth access token - Cannot parse access token"}

from flutterfire.

TarekkMA avatar TarekkMA commented on May 26, 2024 1

I will attempt to reproduce this issue. In the meantime, you might find it helpful to look at a similar issue reported with the Facebook SDK here: facebook-ios-sdk issue #2365. This may provide some insights into the problem you are encountering. Additionally, I suspect that FlutterFire may not be responsible for this error, but I will confirm this as I investigate further.

from flutterfire.

TarekkMA avatar TarekkMA commented on May 26, 2024 1

Hi @RaghvindYadav,

The issue is due to the Facebook SDK/plugin. As mentioned here we need to get the nonce. We'll need a plugin that supports limited login to utilize this updated code snippet:

final provider = OAuthCredential(
  providerId: 'facebook.com',
  signInMethod: 'oauth',
  idToken: accessToken.token,
  rawNonce: rawNonce,
);

from flutterfire.

owllyi avatar owllyi commented on May 26, 2024 1

@owllyi Have you find any solution?

#if UNITY_ANDROID
credential = Firebase.Auth.FacebookAuthProvider.GetCredential(accessToken);
#elif UNITY_IOS
var authToken = FaceBookManager.Instance.GetToken();
var nonce = FaceBookManager.Instance.GetNonce();
credential = Firebase.Auth.OAuthProvider.GetCredential("facebook.com", authToken, nonce, null);
#endif

from flutterfire.

TarekkMA avatar TarekkMA commented on May 26, 2024 1

I've looked into the new package, can you try using this instead and let me know if it works:

      final AccessToken accessToken = result.accessToken!;

      final AuthCredential credential;

      switch (accessToken.type) {
        case AccessTokenType.classic:
          final token = accessToken as ClassicToken;
          credential = FacebookAuthProvider.credential(token.authenticationToken!,);
          break;
        case AccessTokenType.limited:
          final token = accessToken as LimitedToken;
          credential = OAuthCredential(
            providerId: 'facebook.com',
            signInMethod: 'oauth',
            idToken: token.tokenString,
            rawNonce: token.nonce,
          );
          break;
      }

      // Login with token
      await auth.signInWithCredential(credential);

We might need to add a new option in the future for limited login so it can be just FacebookAuthProvider.limitedCredential(....)

from flutterfire.

TarekkMA avatar TarekkMA commented on May 26, 2024 1

I can reproduce this error, I guess the signInMethod should be oauth for it to work, since signInMethod: 'facebook.com' will not use nonce, or the idToken.

/cc @Lyokone

from flutterfire.

RaghvindYadav avatar RaghvindYadav commented on May 26, 2024

@owllyi Have you find any solution?

from flutterfire.

TarekkMA avatar TarekkMA commented on May 26, 2024

Hello @RaghvindYadav,

Thank you for reporting this issue. Based on the link you shared, it appears that the problem may not be related to FlutterFire but rather to the Facebook SDK plugin you are using. Did I understand that correctly? If so, you might consider opening an issue in their respective repository to get further assistance.

from flutterfire.

RaghvindYadav avatar RaghvindYadav commented on May 26, 2024

Hi @TarekkMA
May be you are right but I am getting failed error at this line of code return FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
And FirbaseAuth comes form firebase_auth package.

from flutterfire.

RaghvindYadav avatar RaghvindYadav commented on May 26, 2024

@TarekkMA I did the above you mentioned, still getting the same error.
Also use a new package https://pub.dev/packages/flutter_facebook_auth/versions/7.0.0-dev.3/changelog#700-dev3

from flutterfire.

RaghvindYadav avatar RaghvindYadav commented on May 26, 2024

@TarekkMA I did the above you mentioned, still getting the same error. Also use a new package https://pub.dev/packages/flutter_facebook_auth/versions/7.0.0-dev.3/changelog#700-dev3

Thank you @TarekkMA, I used that package but still persisting with same problem. Now accessToken looks quite different than previous response.

from flutterfire.

RaghvindYadav avatar RaghvindYadav commented on May 26, 2024

@TarekkMA AccessTokenType.limited getting this error for now Firebase Auth error: [firebase_auth/missing-or-invalid-nonce] The nonce in ID Token "C7D21692-B861-4E45-A912-DB9F4502AA2B" does not match the SHA256 hash of the raw nonce "C7D21692-B861-4E45-A912-DB9F4502AA2B" in the request.

If I changed this parameter signInMethod: 'oauth' to signInMethod: 'facebook.com', then app get crashed.

from flutterfire.

onMouseUp avatar onMouseUp commented on May 26, 2024

@owllyi does your implementation work?

var authToken = FaceBookManager.Instance.GetToken();
var nonce = FaceBookManager.Instance.GetNonce();
credential = Firebase.Auth.OAuthProvider.GetCredential("facebook.com", authToken, nonce, null);

Would be interesting how your facebook-login implementation looks like. I got this error:
The nonce in ID Token "xxx" does not match the SHA256 hash of the raw nonce "xxx" in the request

Do you use the hashed nonce or raw nonce in
FB.Mobile.LoginWithTrackingPreference method?

from flutterfire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.