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.

[Identity] Save external tokens automatically on every login

See original GitHub issue

When using Identity with an external authentication provider, the tokens are not saved automatically by the default UI.

I had to scaffold the UI and add the following code to OnGetCallbackAsync to get this to work

await _signInManager.UpdateExternalAuthenticationTokensAsync(info);

The tokens also weren’t saved as part of the account creation flow in OnPostConfirmationAsync and following the instructions in the docs seemed to have no effect https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/additional-claims?view=aspnetcore-3.1

See

                // Include the access token in the properties
                var props = new AuthenticationProperties();
                props.StoreTokens(info.AuthenticationTokens);
                props.IsPersistent = true;

                await _signInManager.SignInAsync(user, props);

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
javiercncommented, Sep 28, 2020

I think so, at least for 6.0.

The external providers flow should work with the default Identity UI, without requiring the user to scaffold the page.

0reactions
msftbot[bot]commented, Nov 17, 2022

Thanks for contacting us.

We’re moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it’s very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Persist additional claims and tokens from external ...
An ASP.NET Core app can establish additional claims and tokens from external authentication providers, such as Facebook, Google, Microsoft, ...
Read more >
asp.net core identity extract and save external login tokens ...
ExternalLoginSignInAsync) the claims from that table are read and added to the cookie that on every request becomes the Principal. So you ...
Read more >
What Are Refresh Tokens and How to Use Them Securely
This post will explore the concept of refresh tokens as defined by OAuth 2.0. We will learn how they compare to other token...
Read more >
persist and refresh access token after external microsoft ...
The issue I'm having now is that the 'access token' only gets set on the INITIAL auto-link of the member. Any access token...
Read more >
JWT authentication: Best practices and when to use it
A token automatically stores this value in the iat property. Every time you check the token, you can compare its iat value with...
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