I am integrating AWS cognito
authentication with social login (facebook/google).
I am follow all the steps as given in documentation but the end return Invalid Access Token
Service: AmazonCognitoIdentityProvider;
Status Code: 400;
Error Code: NotAuthorizedException;
Request ID: 58fc3cfc-1649-11e9-91bc-3fb47a1bd404
Put facebook login in to the crendential provider this code generate identity in my identity pool :
Map<String, String> logins = new HashMap<String, String>();
logins.put("graph.facebook.com",
AccessToken.getCurrentAccessToken().getToken());
credentialsProvider.setLogins(logins);
for creating user in user pool i am using this url:
val url = "https://<my-domain-name>.auth.ca-central-1.amazoncognito.com/oauth2/authorize?redirect_uri=myapp://&response_type=token&client_id=<my-ClientId>&identity_provider=Facebook"
That url creating my user in user pool and return access token and id token in result below :
access_token=eyJraWQiOiJyUXpaTDRUVGt6UDdoU3ZDbVB0NktpTVZDcXB4Z2ZFT3pJckpCWFB0WXZVPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2OTIwZDUwZC0zMTU4LTQwMTYtOTgyMi0wNDc0Yzc1MDFjYjIiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIHBob25lIG9wZW5pZCBwcm9maWxlIGVtYWlsIiwiYXV0aF90aW1lIjoxNTQ3Mjg4NDc0LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAuY2EtY2VudHJhbC0xLmFtYXpvbmF3cy5jb21cL2NhLWNlbnRyYWwtMV9DSFVMbDV5c2wiLCJleHAiOjE1NDcyOTIwNzQsImlhdCI6MTU0NzI4ODQ3NCwidmVyc2lvbiI6MiwianRpIjoiNDE4MjNmNzUtMGFkMC00MTdjLThhOTYtM2JjZDM0NWNlZDQ3IiwiY2xpZW50X2lkIjoiN244Z25tdXFuM3NzZWFnaGNoOGQ2OWRibTIiLCJ1c2VybmFtZSI6IkZhY2Vib29rXzE5NDkyNzI0OTg1MDM3ODcifQ.GhaV996dFl7vx-tdkhhuq5HeSG0K5Tn20arF4M2i6YyRdm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yOUBnbWFpbC5jb20ifQ.dK5D1Z1IIeEGdmDI6mbTV48580Rr26_ekQ7za6GrtGADQpm06Fgvtj2SJhv35u6kI6KVnCbNoRC9ewoGB8QmWFCvL2VI-djdDqbCrHSTKsb9RkG1PsfFXoFezvlv4NROc7p5pFPTrltZVH1oI2nf6bAtcMEp7Cp0v_NaYt8dJ0cdYslIGwikH3Dm1QiNKzoqkkUy1-fjwLRSJ5CiH9eUO8DvzB6VomNOHHN0A5F-EJbIAZFXiD3z9N86TsRyEKSpaR7JhmO20VVVLp_YvpUuY9Nagiknkx3gp08vYCBBro0dTnDDQSsOqfVTlNTI5QZz_7AQXrUl7iyAMcw91mfajw
&token_type=Bearer
&expires_in=3600
In last step I am make get user request and send accessToken
as a parameter.
After hitting this API, I have got Invalid Access Token
Service: AmazonCognitoIdentityProvider;
Status Code: 400;
Error Code: NotAuthorizedException;
Request ID: 58fc3cfc-1649-11e9-91bc-3fb47a1bd404)
Invalid Access Token (Service: AmazonCognitoIdentityProvider;
Status Code: 400;
Error Code: NotAuthorizedException;
Request ID: 58fc3cfc-1649-11e9-91bc-3fb47a1bd404)
Finally got the solution just adding endpoint manually according to my region in my request.Now Facebook and google login working fine with 'AWS Cognito'.