question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetUserInfo 401 error

See original GitHub issue

Hi. 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:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
enkodellccommented, Dec 21, 2019

@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.

0reactions
mobinsevencommented, Dec 23, 2019

Sure, I’ll do it. Happy Holidays.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found