Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify-react Authenticator federated sign in doesn't create user in pool #3875

Closed
michelem09 opened this issue Aug 20, 2019 · 11 comments
Closed
Labels
Auth Related to Auth components/category OAuth For issues related to OAuth question General question React React related issues

Comments

@michelem09
Copy link

** Which Category is your question related to? **
Amplify React

** What AWS Services are you utilizing? **
Cognito

** Provide additional details e.g. code snippets **
When I use my custom sign-in app done with Amplify-react Authenticator HOC and I use a social provider such as Facebook, the user sign-in but no user pool is created.

This seems to work only if I use the Hosted UI, in that case if I sign-in with Facebook I get the user created in pool as EXTERNAL_PROVIDER.

Is this wanted? Why? Is there a workaround such a lambda trigger from social sign-in I can use to create the user in pool?

I also can't find a lambda that's triggered when a user sign-in with social identity such as Facebook or Google. Is there?

@elorzafe
Copy link
Contributor

@michelem09 thanks for your question. You are correct, if you do social sign using authenticator it wont create the user on your userpool, and as you mention it will be created only if you use hosted UI.
There are security reasons to not create the user on the userpool without hosted UI flow. Do you have any specific reason to not use Hosted UI?

You can use Hosted UI, in a similar way as Authenticator component by using withOAuth HOC. For more information you can take a look here

@elorzafe elorzafe added Auth Related to Auth components/category question General question React React related issues pending-close-response-required OAuth For issues related to OAuth labels Aug 20, 2019
@michelem09
Copy link
Author

Well, basically I need to modify the form a bit, for example I need to put a checkbox to let user accept the TOS in the signup and with Hosted UI I can't do that.

I will investigate withOauth HOC.

@elorzafe
Copy link
Contributor

@michelem09 let me know how it goes.

@michelem09
Copy link
Author

Unfortunately I have other priorities now, but I will come back on this ASAP. Thanks

@michelem09
Copy link
Author

I cannot understand how this works, I don't want to redirect my users to the HostedUI website.

@TOPSinfo
Copy link

TOPSinfo commented Nov 9, 2019

Has there been any update on this?

@haverchuck
Copy link
Contributor

@TOPSinfo @michelem09 There are two ways to federate with social providers in Cognito: with Identity Pools or with User Pools (via Hosted UI). If you are federating with Identity Pools (which seems to be the case) a user will not be create automatically in the User Pool... you will simply see an 'Identity' in the Identity Pool.

You note that you do not want to use the Hosted UI. If your objection is based only on the fact that you do not want to use the Hosted UI interface, then you can work around this issue; it is possible to use the Hosted UI functionality without actually directing users to the Hosted UI interface. This can be accomplished by calling Auth.federated signIn with a provider parameter in the options, like so:

<button onClick={() => Auth.federatedSignIn({provider: 'Google'})}>Open Google</button>

This will route users to Hosted UI, which will immediately redirect them to the Google login/account selection/consent screens. The user will then be passed back to your application and Amplify will handle the tokens in the OAuth response. A user should also be created in the User Pool.

I hope this helps.

@michelem09
Copy link
Author

@haverchuck that's great, let me try it. Thanks

@haverchuck
Copy link
Contributor

Closing this issue due to inactivity.

@JiboStore
Copy link

@haverchuck Hi, according to your reply above:
There are two ways to federate with social providers in Cognito: with Identity Pools or with User Pools (via Hosted UI). If you are federating with Identity Pools (which seems to be the case) a user will not be create automatically in the User Pool... you will simply see an 'Identity' in the Identity Pool.

I am using hosted-ui (by calling Auth.federatedSignIn) thus the user is created in the user pool.. I don't want the user to be created in the user pool, is there a way to use hosted-ui (Auth.federatedSignIn) without it created in user pool?

P.S: I have tried changing and/or removing federatedTarget: "COGNITO_IDENTITY_POOLS" in the aws-exports to no avail...

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category OAuth For issues related to OAuth question General question React React related issues
Projects
None yet
Development

No branches or pull requests

5 participants