I am trying to integrate aws cognito with google auth for my react app and i am having trouble completing the flow. Can anyone help me on this please and guide me thanks
Amplify.configure({ Auth: { identityPoolId: process.env.REACT_APP_AWS_IDENTITY_POOL_ID, //REQUIRED - Amazon Cognito Identity Pool ID region: process.env.REACT_APP_AWS_USER_POOL_REGION, // REQUIRED - Amazon Cognito Region userPoolId: process.env.REACT_APP_AWS_USER_POOL_ID, //OPTIONAL - Amazon Cognito User Pool ID userPoolWebClientId: process.env.REACT_APP_AWS_USER_POOL_WEB_CLIENT_ID, //OPTIONAL - Amazon Cognito Web Client ID oauth: { domain: process.env.REACT_APP_AWS_COGNITO_DOMAIN, scope: ['email', 'profile', 'openid'], redirectSignIn: process.env.REACT_APP_REDIRECT_SIGNIN, redirectSignOut: process.env.REACT_APP_REDIRECT_SIGNOUT, responseType: 'code', // or 'token' depending on the OAuth flow you want to use }, },})
my amplify setup looks like this
const handleGoogleSignIn = async () => {try {await Auth.federatedSignIn({ provider: 'Google' });} catch (error) {console.error('Error with Google Sign-In:', error);}};
i am trying to sign in to google with cognito but everytime i click this button it goes to url http://localhost:3000/?error_description=unauthorized_client&state=b90qsaNKVytvPbRfoxc2eOiMoWBKSvc6&error=invalid_request
and comes back to localhost. When i do it in the hosted UI in aws app client in user pool it opens up sign in with google button and completes that flow returning a token. But when i do in my app it doesn’t work.
I am using my domain for cognito as Authorised redirect URIs in google console aswell as the Authorised JavaScript origins my redirect urls are http://localhost:3000
what am i doing wrong can anyone here guide me. Thank you
Ali Javed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.