Issue
I'm currently trying to use @react-native-google-signin
library in my React Native project to log in a user in my app and then authenticate him on my cognito user pool using was-amplify. So basically without using the hosted UI
Currently, I have this in my app:
function GoogleSignInButton() {
const handleGoogleSignIn = async () => {
const {idToken, user} = await GoogleSignin.signIn();
const jwtClaims = parseJwt(idToken);
const googleCredentials = await Auth.federatedSignIn('google', { token: idToken, expires_at: jwtClaims.exp }, user);
};
render(
<Button title={'Google Sign In'} onPress={handleGoogleSignIn}/>
);
}
The GoogleSignIn part works perfectly and returns correctly both the idToken and the user properties.
However, when I call the Auth.federatedSignIn(...) returned me the error:
NotAuthorizedException: Token is not from a supported provider of this identity pool.
I'm pretty sure I configured correctly the AWS Cognito user pool, since if I access the hosted UI I can successfully log in and register a user
I configured google as a federated identity provider in my user pool
I also saw some confusing documentation that led me to add the google identity provider to the identity pool linked to my user pool, like this:
However, I then received this error:
InvalidIdentityPoolConfigurationException: Invalid identity pool configuration. Check assigned IAM roles for this pool.
Which lead me to believe that this is probably not the right direction.
So going to the original issue: how is it possible that it's not realizing that the token comes from google which is the specified identity provider?
Solution
I also tried this solution and got the same results as you. I recommend to watch this video Lesson 4.1 OAuth and React Native (Google Login). From what I understood we need to use Identity pools
from the left side menu. This can be helpful https://stackoverflow.com/a/75291833/10617148
Also, I tried another solution React Native App Auth with the same results.
Answered By - Vasyl Nahuliak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.