Currently, I am trying to implement Social Login for my web Application using Cognito Aws Service. But I don't want to redirect the user to Cognito Hosted UI for Social Login.
So I use react-google-login for the Google Login and I am getting the callback access token too
<GoogleLogin
clientId="xxxxxxxxxxxxxx.apps.googleusercontent.com"
buttonText="Login"
onSuccess={this.responseGoogle}
onFailure={this.responseGoogleFailure}
cookiePolicy={'single_host_origin'}
/>
responseGoogle = async (response) => {
console.log("response..........", response);
const user = {
name: response.profileObj.name,
email: response.profileObj.email
};
let expires_at = 3600 * 1000 + new Date().getTime()
Auth.federatedSignIn('google', { token: response.tokenId, expires_at }, user).then(credentials => {
console.log(credentials);
});
}
The above code gives the Cognito session values but that doesn't create a user in the user pool.
I have search a lot but didn't find any solutions. I have already referred this below links it refers to my problem. Basically I don't want to use hosted UI for the SocialLogin.
Thank In advance
https://github.com/aws-amplify/amplify-js/issues/1316
https://github.com/aws-amplify/amplify-js/issues/3875
Sign in to the Amazon Cognito console . In the navigation pane, choose User Pools, and choose the user pool you want to edit. Choose the App integration tab. To customize UI settings for all app clients, locate Hosted UI customization and select Edit.
You can also use a keyboard shortcut to open an Incognito window: Windows, Linux, or Chrome OS: Press Ctrl + Shift + n. Mac: Press ⌘ + Shift + n.
Go to AWS Cognito service and click “Manage Identity Pools”. 2. Enter “Identity pool name”, expand the “Authentication providers” section and select “Cognito” tab. This is where the Cognito authentication provider will be registered with the Identity pool.
It is possible to open the link directly to the Google login page without showing the hosted ui but still have the authentication go through Cognito, you basically link directly to the url which is opened when you select the Google button in the Cognito hosted ui i.e.
https://<YOUR_DOMAIN>.auth.<REGION>.amazoncognito.com/oauth2/authorize?identity_provider=Google&redirect_uri=<REDIRECT_URI>&response_type=TOKEN&client_id=<CLIENT_ID>&scope=openid
You will end up back at your redirect uri after the auth and the user will have been created/authenticated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With