[Identity] Save external tokens automatically on every login
See original GitHub issueWhen 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:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
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.
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.