flutter_cognito_plugin icon indicating copy to clipboard operation
flutter_cognito_plugin copied to clipboard

Facebook federated signin not working?

Open yuensunn opened this issue 6 years ago • 4 comments

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)

yuensunn avatar Nov 11 '19 11:11 yuensunn

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 :)

samuelchanx avatar Dec 03 '19 12:12 samuelchanx

Thanks a lot @samuelchanx ! Will give it a try

yuensunn avatar Dec 04 '19 03:12 yuensunn

@yuensunn were you able to get this working?

robert-stevens avatar Mar 24 '20 11:03 robert-stevens

https://programmingproalpha.blogspot.com/2020/08/how-to-make-facebook-log-in.html

MohammadUzair1 avatar Sep 01 '20 14:09 MohammadUzair1