amazon-archives / amazon-cognito-auth-js

The Amazon Cognito Auth SDK for JavaScript simplifies adding sign-up, sign-in with user profile functionality to web apps.
Apache License 2.0
423 stars 232 forks source link

Save Facebook User into Userpool using Custom UI #55

Closed joe455 closed 6 years ago

joe455 commented 6 years ago

I am using cognito auth for custom UI facebook login in local environment. It is prompting for facebook credentials but on redirecting it is showing invalid request.Any Idea on this?

jonasao commented 6 years ago

Have you entered the correct redirect value in your AWS Cognito user pool?

yuntuowang commented 6 years ago

@jonasao is correct. Can you check your redirect URL setting under app client settings are consistent with the one you configured in your project? @joe455

joe455 commented 6 years ago

my configuration in project is something like this.

const authData = { ClientId: '**************', AppWebDomain : 'localhost:4200', TokenScopesArray : ['profile', 'email'], //TokenScopesArray : ['profile', 'email', 'openid', 'aws.cognito.signin.user.admin', 'phone'], RedirectUriSignIn : 'http://localhost:4200/home', RedirectUriSignOut : 'http://localhost:4200/home' };

and cognito seettings redirect url is 'http://localhost:4200/home'

Any mistake in this? @jonasao @yuntuowang

joe455 commented 6 years ago

Now its redirecting to https://localhost:4200/oauth2/authorize?redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Fhome&response_type=token&client_id=*&state=&scope=profile%20email when I change it to https to http I am getting angular error(For obvious reason though)

Error: Cannot match any routes. URL Segment: 'oauth2/authorize'

@jonasao @yuntuowang I there is any problem with my domain name?

yuntuowang commented 6 years ago

Hi @joe455 , currently we don't support http schema. Also, for "AppWebDomain" field, it is set in your Cognito console "Domain name" tab. For example: "etgbnhwr.auth.us-east-1.amazoncognito.com". The example hosted UI endpoint: https://hew.auth.us-east-1.amazoncognito.com/oauth2/authorize?response_type=token&client_id=58kqn2ob56dh750&redirect_uri=https://www.amazon.com (This endpoint is not a valid one, just serve as an example.)

joe455 commented 6 years ago

Is there any possibility to achieve same thing with the custom UI? @yuntuowang

yuntuowang commented 6 years ago

@joe455 Do you mean you want to use your own UI but not our hosted UI page? Actually our hosted UI is customizable. You can change color and a lot more with the parts of the page.

joe455 commented 6 years ago

@yuntuowang Yes, I know the possibilities with the hosted UI. I tried everything over there. Although my client needs custom UI(App with angular4). Is there any possibility for this? Any SDK/documentation or anything related for this?

yuntuowang commented 6 years ago

Hi @joe455 , I totally understand your need for your clients. Currently we don't support using your own UI. However, I will mark this as a feature request and discuss during our meetings. I will post on this issue once we have any new status. Thanks a lot!

joe455 commented 6 years ago

Thanks @yuntuowang Looking forward to that feature.Thanks for your support !!!!

yuntuowang commented 6 years ago

@joe455 You are very welcome!!! Let me know if you have any other questions.

yuntuowang commented 6 years ago

As mentioned in https://github.com/aws/amazon-cognito-auth-js/issues/62, you are able to save the facebook user into userpool, closing this.

joe455 commented 6 years ago

I am able to save the federated users into userpool without using hosted UI(By providing IdentityProvider attribute). Thanks a lot 👍

yuntuowang commented 6 years ago

Hi @joe455, you are very welcome!! Glad it works!!

Jun711 commented 6 years ago

@joe455 Hi Joe, just wonder if you could share a gist of your working copy. thanks. just wonder if you are using aws amplify to save fb users into a userpool.

engharb commented 6 years ago

@joe455 @yuntuowang I have the same problem. When using Hosted UI in my Web app the FB login process works perfect and then the identity provider instance is linked/merged in user pool. But that's does not work in Mobile Apps. Therefore I am using Ionic Facebook to login (not Hosted UI), my question is @joe455 how did you succeeded in using IdentityProvider attr to link the fb_identityId in user pool?

regards,

guilhermedecampo commented 6 years ago

@engharb did you find how to configure FB login to link/merge in user pool? I have a custom implementation too and it's being super hard to configure and find information about it.

engharb commented 6 years ago

@guilhermedecampo I have integrated aws/amplify as upper layer lib. there you can simplify your implementation for login process ... What you need is to call a function i.e signInFederation() but this does not add the signed in user to the user pool. What you can do is using Customization UI, there the signed in user will automatically linked to user pool and you will get the required token as returned params in URL. The gab here is how to store and refresh these tokens in your local storage. I tried manually but didn't succeeded.

you can follow this blog: https://aws.amazon.com/blogs/aws/launch-amazon-cognito-user-pools-general-availability-app-integration-and-federation/

If you have any suggestions let's know.

gitsome commented 6 years ago

I see a solution for adding federated user to user pool was found. @yuntuowang was the feature of supporting custom UI for this ever added to the Amplify roadmap? We are federating users via a social idp and need User Pool support but would really love more control over the user experience during the login process.

yuntuowang commented 6 years ago

Hi @gitsome, adding support of custom UI will be a feature request from Cognito service side. At this point, I cannot comment on the delivery time.