-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firebase Auth: We need to upgrade package with new changes made in Facebook Login for iOS #12713
Comments
same issue in my unity game. Error Message: Firebase.FirebaseException: Bad access token: {"code":190,"message":"Invalid OAuth access token - Cannot parse access token"} |
@owllyi Have you find any solution? |
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. |
Hi @TarekkMA |
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. |
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,
); |
@TarekkMA I did the above you mentioned, still getting the same error. |
#if UNITY_ANDROID |
Thank you @TarekkMA, I used that package but still persisting with same problem. Now accessToken looks quite different than previous response. |
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 |
@TarekkMA AccessTokenType.limited getting this error for now If I changed this parameter |
I can reproduce this error, I guess the signInMethod should be oauth for it to work, since /cc @Lyokone |
@owllyi does your implementation work? var authToken = FaceBookManager.Instance.GetToken(); Would be interesting how your facebook-login implementation looks like. I got this error: Do you use the hashed nonce or raw nonce in |
Found a solution. This is what I found in firebase documentation: "You will send the SHA-256 hash of the nonce with your sign-in request, which Facebook will pass unchanged in the response. Firebase validates the response by hashing the original nonce and comparing it to the value passed by Facebook." Facebook-Login: Firebase Credentials: |
I'm having this issue too with Flutter on IOS. The same code worked less than two months aga. The problem only occurs for me on IOS, not on Android. |
after reading this thread I tried it on iphone 14 running iOS 16.4 in IOS Emulator. It works there. In iOS 17.4 it fails. |
Workaround (downgrade facebook sdk version): After this my old code works on physical device iPhone 11 iOS 17.4.1 |
Firebase Auth iOS has documentation on how to login with limited login here: https://firebase.google.com/docs/auth/ios/facebook-login#implement_facebook_limited_login The difference is, they create a nonce, and send a SHA-256 hash of the nonce to FacebookAuth, whilst passing in the raw nonce to firebase_auth OAuthCredential credential = OAuthCredential(
providerId: 'facebook.com',
signInMethod: 'oauth',
idToken: token.tokenString,
rawNonce: rawNonce,
); The above will work for limited login if you set it up correctly. |
Any update on this? I have the same issue. |
I found the workaround provided by @usilitel to work on IOS emulators and physical devices up to IOS 17.4.1. I haven't tried the method presented by @russellwheatley thus far, but if there are any thoughts as to "why?" downgrading works and the current version doesn't, and how if at all it relates to the issue described by @russellwheatley that would be of tremendous assistance. Thank you both though. |
This worked for me using flutter_facebook_auth: ^7.0.0 String sha256ofString(String input) {
final bytes = utf8.encode(input);
final digest = sha256.convert(bytes);
return digest.toString();
}
String generateNonce([int length = 32]) {
final charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-.';
final random = Random.secure();
return List.generate(length, () => charset[random.nextInt(charset.length)]).join();
}
Future signInWithFacebook() async {
// Trigger the sign-in flow
final rawNonce = generateNonce();
final nonce = sha256ofString(rawNonce);
final result = await FacebookAuth.instance.login(
loginTracking: LoginTracking.limited,
nonce: nonce,
);
if (result.status == LoginStatus.success) {
print('${await FacebookAuth.instance.getUserData()}');
final token = result.accessToken as LimitedToken;
// Create a credential from the access token
OAuthCredential credential = OAuthCredential(
providerId: 'facebook.com',
signInMethod: 'oauth',
idToken: token.tokenString,
rawNonce: rawNonce,
);
await FirebaseAuth.instance.signInWithCredential(credential);
}
} |
Hey @RaghvindYadav. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Since there haven't been any recent updates here, I am going to close this issue. @RaghvindYadav if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
Is there an existing issue for this?
Which plugins are affected?
Auth
Which platforms are affected?
iOS
Description
I am integrating my app with Facebook login but facing a problem in iOS version which is greater than 17.0. The login get failed.
Getting error : Firebase Auth error: [firebase_auth/invalid-credential] {"code":190,"message":"Invalid OAuth access token - Cannot parse access token"}
Reproducing the issue
The above is worked well for android and iOS device which ios version is less than 17, but we need to upgrade Facebook sign for iOS 17.o and greater.
Here is a url of blog. https://developers.facebook.com/blog/post/2024/03/28/changes-made-to-fb-login-sdk/
Firebase Core version
2.30.1
Flutter Version
3.19.5
Relevant Log Output
Flutter dependencies
Additional context and comments
https://developers.facebook.com/blog/post/2024/03/28/changes-made-to-fb-login-sdk/
The text was updated successfully, but these errors were encountered: