Open khushal-chothani opened 1 month ago
Hi @darwin-morocho
I checked that code and i used code which in example of this repo
Future
setState(() {
_state = LoginLoading();
});
final result = await _auth.login(
loginTracking: LoginTracking.limited,
nonce: _nonce,
);
switch (result.status) {
case LoginStatus.success:
await _getUserProfile(result.accessToken!);
AuthCredential credential = FacebookAuthProvider.credential(result.accessToken!.tokenString);
UserCredential user = await FirebaseAuth.instance.signInWithCredential(credential);
print(user);
case LoginStatus.cancelled:
case _:
log(
'${result.status.name}: ${result.message}',
);
setState(() {
_state = LoginNotAuthenticated();
});
}
}
here additional line is
AuthCredential credential = FacebookAuthProvider.credential(result.accessToken!.tokenString); UserCredential user = await FirebaseAuth.instance.signInWithCredential(credential); print(user);
Which throws error - [firebase_auth/invalid-credential] {"code":190,"message":"Bad signature"} So plugin works but it's giving the wrong token or i am not sure but firebase core rejecting for signInWithCredential login and throws : - [firebase_auth/invalid-credential] {"code":190,"message":"Bad signature"}
Hi @darwin-morocho
I checked that code and i used code which in example of this repo
Future
_login() async { _nonce = generateNonce(); setState(() { _state = LoginLoading(); }); final result = await _auth.login( loginTracking: LoginTracking.limited, nonce: _nonce, ); switch (result.status) { case LoginStatus.success: await _getUserProfile(result.accessToken!); AuthCredential credential = FacebookAuthProvider.credential(result.accessToken!.tokenString); UserCredential user = await FirebaseAuth.instance.signInWithCredential(credential); print(user); case LoginStatus.cancelled: case _: log( '${result.status.name}: ${result.message}', ); setState(() { _state = LoginNotAuthenticated(); }); }
}
here additional line is
AuthCredential credential = FacebookAuthProvider.credential(result.accessToken!.tokenString);
UserCredential user = await FirebaseAuth.instance.signInWithCredential(credential); print(user);
Which throws error - [firebase_auth/invalid-credential] {"code":190,"message":"Bad signature"}
So plugin works but it's giving the wrong token or i am not sure but firebase core rejecting for signInWithCredential login and throws : - [firebase_auth/invalid-credential] {"code":190,"message":"Bad signature"}
The example code is not valid for firebase auth. You need to pass to firebase the raw nonce.
https://github.com/darwin-morocho/flutter-facebook-auth/issues/397#issuecomment-2187411186
What version are you using?
flutter_facebook_auth: ^6.0.3.
What OS and version are you using to local deploy your application?
macOs 14.6.1
What platforms are you seeing the problem on?
iOS
pubspec.yaml
Describe the Bug
When using facebook login method i'm facing issue related to token
this is my code
Future signInWithFacebook() async {
try {
final LoginResult loginResult = await FacebookAuth.instance.login(permissions: ['public_profile']);
}
Expected Behavior
Expected behaviour is token should be valid and it should be login in using facebook
To Reproduce
To Reproduce Use given or even latest package Do setup in IOS
Then when we use facebook login method then first it will create login result then after creating AuthCredential pass that cred to signInWithCredential method and facing this issue in IOS only
Relevant log output
flutter doctor -v
Info.plist (iOS)
Podfile (iOS)
AndroidManifest.xml
MainActivity.java
MainActivity.kt
index.html
Info.plist (macOS)