-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Identity providers authentication against User Pools WITHOUT hosted UI #1316
Comments
Hi @martimarkov Currently it is not possible, but the good news is that this is currently in the roadmap. Please stay tuned! |
I did find I workaround by copying the code from the hosted us version and listing for the events using Hub.
Thanks,
Marti Markov
… On 26 Jul 2018, at 20:01, Manuel Iglesias ***@***.***> wrote:
Hi @martimarkov
Currently it is not possible, but the good news is that this is currently in the roadmap. Please stay tuned!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@martimarkov we find a solution for you to use the customized button to do that. You can construct a url like |
@powerful23 does it work for other providers too ? (google, amazon ) |
@akash87 It works for google but not sure for Amazon because I didn't add it as one of the providers in my Cognito User Pool settings. |
This is great, thanks!! |
@powerful23 What do I do with the response from Do I call |
Hi! Thanks for the great work around it works well. @peetss yes you need call the federatedSignIn first and after navigate to the custom url and you will get the JWT tokens. I've only one question. How do you refresh the token after you get that, because It does not contain any refresh token? @powerful23 Could you give me a hint please? Thanks again! |
@peetss for now it's not completely integrated into the library but you can use a work around like: import { CognitoAuth } from 'amazon-cognito-auth-js';
const params = {
ClientId,
UserPoolId,
AppWebDomain,
TokenScopesArray,
RedirectUriSignIn,
RedirectUriSignOut,
ResponseType,
Storage
}
const cognitoAuthClient = new CognitoAuth(params);
cognitoAuthClient.userhandler = {
// user signed in
onSuccess: (result) => {
Auth.currentSession().then(async (session) => {
// ...
});
},
onFailure: (err) => {
logger.debug("Error in cognito hosted auth response", err);
}
};
const curUrl = window.location.href;
cognitoAuthClient.parseCognitoWebResponse(curUrl); The params are basically the same with https://aws-amplify.github.io/amplify-js/media/authentication_guide#configuring-the-hosted-ui @bajzat if there is no refresh token, then you will need to log the user out when the token is expired. |
Would someone (@bajzat @peetss) mind sharing out the snippet before the storage of the cognito token workaround? I'm unclear on how you're invoking the oauth url after the Auth.federatedSignIn call. I'm using the Facebook federated identity approach and it looks like from my react app I need to call the Cognito Oauth2 url, that then calls Facebook Oauth (https://your-cognito-domain/oauth2/idpresponse), which redirects back to Cognito and then my app. |
@powerful23 hello again :) |
@powerful23 are there any updates on how to get a refresh token via this method? |
@ardsouza if you mean how to get the refresh token via Cognito Hosted UI, you need to set the |
@powerful23 so it's not possible to get refresh token with response type :token
|
|
@powerful23 Thanks for your reply.
|
Hello! i used this workaround for now:
and it worked! at least until the feature is live. you can get the expiration time decoding the JWT access token. |
@ngrosso is it working with above approach for custom idp ? if yes can you please provide me full example and which library is it amplify angular or amazon-cognito-auth-js |
|
@powerful23 Ok thanks |
I'm getting this response: https://localhost:8080/#error_description=unauthorized_client&error=invalid_request Any ideas? I'm able to bring up the hosted UI directly so I'm pretty sure my DOMAIN and CLIENTID are correct. Wish this was easier! |
Well, this is a cleaner way to user pools with AppSync. I'm not sure if we can find this in the docs. |
Hello everyone, we have created an RFC for feature work that should make the challenges found in this issue easier in the future. If you have a moment please read through the details and add any comments: #2716 Your feedback in the RFC will help us ensure that we are delivering the best experience possible. Thank you. |
@uclaeagit would you mind sharing what's involved in your postLogin() ?
See comment above. When I navigate to the authenticated app(and call getCurrentAuthenticatedUser()) it seems as though my logged in user is gone again, any help on this would be greatly appreciated. |
Sure, here's doPostLogin with some comments:
We do some other stuff with user that won't matter to you. But I think awaiting the Auth.currentAuthenticatedUser() call is the key for you. I just tested with our our getUser() call and it still works, so it's not because that is delaying it or anything. |
@uclaeagit Thank you for your response.
The console.log(user) does log a cognito user though which is great so thank you. |
Using amplify for everything so far. |
I used the instructions provided here (https://serverless-stack.com/chapters/facebook-login-with-cognito-using-aws-amplify.html) to integrate federated login with Then I use |
@peetss those instructions are valid for federated identities with an identity pool not federated login with user pools. |
I believe there is a lot of confusion between identity pool and federated login with user pools. I don't think this is a problem with Amplify, it's Cognito's documentation. |
@0x6C38 Ahhh yes it is. What is the use case for using federated identities with user pools? AFAIK you will save a lot if you leverage identity pool vs saving all federated identities to user pool. |
@peetss using a cognito user pool with groups allows for easy, granular authorization that is a lot more difficult with identity pools. Other than that I have no use for an identity pool if I can do federated login through the user pool. |
@0x6C38 Ah, what do you find to be more difficult in using identity pools for authorization? |
@peetss my use-case: I store users in user pool. Each user belongs to a group, depending on which he has access to different appsync urls. userId (sub) is also part of rows in dynamodb, where it is clear which data belongs to user. Let's say I have a row like this in Dynamo: How can achieve similar logic using identity pool? |
I've tried all the possibilites but no chance to save facebook/google users into user pools. I'm using Auth.federatedSignIn, can display email,name but still don't save in user pools. What should I do after Auth.federatedSignIn? Thank you! |
Is this #1316 (comment) in Amplify now? |
I'm dealing with the same issue as @AdrianRealDevs. I've got the federatedSignIn working fine with I was previously using the Hosted UI (and it did create users in the user pool), but I found that the user experience is more customize-able by doing it manually. It would be nice if there was some option in federated sign in to store the user in the user pool as well. For now, I'll probably trigger a Lambda that uses admin rights to create the social user during the sign up process. |
@kylegwalsh It seems you have to redirect to Hosted-UI to let create the user in the user pool, they suggest to use Furthermore, I also was thinking to use a lambda but I didn't find any lambda triggered by Auth.federatedSignIn, did you do? |
I ended up reverting to Hosted-UI due to the issue I cited above. When I was doing it manually, I did like the fact that I could trigger a popup window rather than temporarily redirecting the user away from my site, but I determined it was not worth the headache of trying to manually manage everything. In addition I configured Hosted-UI to use a subdomain of my site (auth.mysite.com) so that I didn't have to rely on the random URL they generated. |
@manueliglesias is this supported now ? |
@peetss Did you use it to create a User Pool user for FB / Google / other IdP logged in users? |
Mainly I used this |
Any updates? |
As of the implementation of #2716 you can call |
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 |
Allow for custom UI (self-hosted, not the poorly customizable hosted UI) when using User Pools.
Currently, I have to redirect my customers to a page I have 10% control over how it looks. I can't change the font or the layout. I'm using react and have already built my desired flow. I only want to be able to get a JWT from Cognito for a person who decides to signup with Facebook or Google.
If I use Federated Identities I get a Facebook token. If there is a way to then "exchange" that for a JWT issued by Cognito I'll be happy as well.
The text was updated successfully, but these errors were encountered: