Future<User?> signInWithFacebook() async {
try {
// Trigger the Facebook Authentication flow
final LoginResult result = await FacebookAuth.instance.login();
if (result.status == LoginStatus.success) {
final accessToken = result.accessToken!;
print('AccessToken type: ${accessToken.runtimeType}');
print('AccessToken properties: ${accessToken.toString()}');
// Create a credential using the token
final OAuthCredential credential = FacebookAuthProvider.credential(accessToken.token);
return _auth.authStateChanges();
}
}
no matter what i did. I couldn't resolve this issue
It just doesnt get the token. How can i resolve this man i am stuck here 2 hours. HOW HARD CAN IT BE
Change this:
final OAuthCredential credential = FacebookAuthProvider.credential(accessToken.token);
into this:
final OAuthCredential credential = FacebookAuthProvider.credential(accessToken!.tokenString);
The class AccessToken
no longer has a property called token
, instead now it's tokenString
.
You can check here: