Facebook federated signin not working?
Currently using the latest flutter_cognito_plugin from git and flutter_facebook_login: 3.0.0 for the facebook login function. Here is my code.
facebookLogin.logIn(['public_profile', 'email']).then((result) {
print(result.accessToken.token);
// passing user access token into the token field
Cognito.federatedSignIn("Facebook", result.accessToken.token)
.then((res) {
print(res);
c.complete(res);
});
}).catchError((error) {
c.completeError(error);
});
Error that I am getting
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(com.amazonaws.services.cognitoidentity.model.NotAuthorizedException, Invalid login token. Not a valid OpenId Connect identity token. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: a6f64c73-244b-452c-a869-0d207582b254), com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Invalid login token. Not a valid OpenId Connect identity token. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: a6f64c73-244b-452c-a869-0d207582b254)
It should be graph.facebook.com, not Facebook. As shown on the AWSMobileClient below:
AMAZON("www.amazon.com"),
FACEBOOK("graph.facebook.com"),
GOOGLE("accounts.google.com"),
TWITTER("api.twitter.com"),
DEVELOPER("cognito-identity.amazonaws.com"),
https://github.com/aws-amplify/aws-sdk-android/blob/e1f9c8121afb567c075782328a9d38b3863a0db6/aws-android-sdk-mobile-client/src/main/java/com/amazonaws/mobile/client/IdentityProvider.java#L25
This works like a charm for me :)
Thanks a lot @samuelchanx ! Will give it a try
@yuensunn were you able to get this working?
https://programmingproalpha.blogspot.com/2020/08/how-to-make-facebook-log-in.html