-
Notifications
You must be signed in to change notification settings - Fork 694
Read userprofile info without HTTP call #416
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
Comments
Not to invalidate your question, but out of curiosity and to get some context: why are you asking the question? What is your use case? Either way, if I do this: console.log(this.oauthService.getIdentityClaims()); At the very start of my wrapper auth-service (so before any call to load login and whatnot) I will see:
so as far as I can tell, the library already does this for you. You can start using any claims saved in storage without doing Of course that information might be outdated or even expired, but I think you could use All this assumes you're using implicit flow with OpenID, of course. |
Hi Jeroen, I have an Angular 6 application with implicit flow with OpenID and Thinktecture IdentityServer4. Do you have any suggestion? Maybe a solution enrich identity token with custom claims that I have to use in AuthGuard? Thank you for your support! |
You could try to embrace the async nature of the OAuthService and make your auth guard async as well. I outlined in my sample repository how you could make the auth guard wait for the initial load (including loadUserProfile, if you want) of things before returning. Another option, although I'm not familiar with Thinktecture, might be to append specific claims to the access token. Given that some of your claims restrict/give access, this doesn't seem so weird. And then you would have the claims available immediately if storage already had them. At the moment we ourselves use the first option. Your question prompted the second option, and I might even consider moving to that if I find the time. |
Thank you Jeroen for sharing repository. |
Hi,
I have a question... whenever loadUserProfile method is used, UserProfile endpoint is called with an HTTP request.
The result of HTTP call is stored in AuthStorage (loadUserProfile() - row 593)
this._storage.setItem('id_token_claims_obj', JSON.stringify(info));
Is it possible use
id_token_claims_obj
directly in own code without invoking loadUserProfile and obviously without HTTP call?Or do you suggest to save using event handler in a custom sessionStorage variable?
Thanks
Giorgio
The text was updated successfully, but these errors were encountered: