GetUserInfo 401 error
See original GitHub issueHi.
Summary:
A 401 error is returned by GetUserInfo
when user in not logged in. Causes a dummy browser login request (in some cases).
Steps to reproduce:
Browse the app without logging in.
Resolution:
The GetUserInfo
in IdentityAuthenticationStateProvider
class is requesting to get the user info even though it knows user is not logged in. So, I propose this structure for GetUserInfo
:
public async Task<UserInfoDto> GetUserInfo()
{
if (_userInfoCache != null && _userInfoCache.IsAuthenticated)
{
_userInfoCache = await _authorizeApi.GetUserInfo();
return _userInfoCache;
}
//If the user is not authenticated then an empt UserInfoDto is returned
//_userInfoCache = await _authorizeApi.GetUserInfo();
return new UserInfoDto();
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
401 Error to authorize user - Questions
You seem to be mismatching the authorization server that issued the token, the “Default” Custom Authorization Server, with the one that you are ......
Read more >The /userinfo endpoint returns 401 (Unauthorized)
The 401 error happens when performing the following call: lock.getUserInfo(authResult.accessToken, (error, profile) => ...).
Read more >Docusign UserInfo endpoint returns 401 Unauthorized ...
UserInfo GetUserInfo (string accessToken); ... I have now been able to get the base_uri from UserInfo endpoint using the RequestJWTUserToken ...
Read more >getUserInfo REST API response with 401 by using scope " ...
I am developing a Android Mobile Email App to connect outlook imap/smtp server by Oauth2 to pull/send Email by outlook account.
Read more >Get UserInfo return 401 Unauthorized · Issue #16844
In shortcut, UserInfo is OIDC specific endpoint when service-accounts (client credentials) is OAuth2 thing. So the fact that UserInfo works just ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mobinseven Thanks I agree there is an issue here. But implementing your suggestion causes a side effect. The login doesn’t work after implementation.
I think the real solution is removing the [Authorize] from the server API call api/Account/UserInfo and returning an Anonymous UserProfile. I think it was accidentally added during the IS4 refactor. I will push that change.
Sure, I’ll do it. Happy Holidays.