ASP.NET Core 3.1 API - JWT Authentication with Refresh Tokens
Documentation and instructions available at https://jasonwatmore.com/post/2020/05/25/aspnet-core-3-api-jwt-authentication-with-refresh-tokens
ASP.NET Core 3.1 API - JWT Authentication with Refresh Tokens
Home Page: https://jasonwatmore.com/post/2020/05/25/aspnet-core-3-api-jwt-authentication-with-refresh-tokens
License: MIT License
ASP.NET Core 3.1 API - JWT Authentication with Refresh Tokens
Documentation and instructions available at https://jasonwatmore.com/post/2020/05/25/aspnet-core-3-api-jwt-authentication-with-refresh-tokens
GET https://localhost:44376/users
Using Postman selected 'Bearer Token' and pasted the jwtToken value into the token field and it comes back with a 500 Internal Server Error.
Using:
Microsoft Visual Studio Community 2019
Version 16.9.5
Postman 8.5.1
Thanks for this example I am trying to implement as you didn't show another controller can you tell me how I consume it taking into account that the user is already authenticated.
When I try to revoke the token the request will fail in line 5:
1. private (RefreshToken, Account) getRefreshToken(string token)
2. {
3. var account = _context.Accounts.SingleOrDefault(u => u.RefreshTokens.Any(t => t.Token == token));
4. if (account == null) throw new AppException("Invalid token");
5. var refreshToken = account.RefreshTokens.Single(x => x.Token == token);
6. if (!refreshToken.IsActive) throw new AppException("Invalid token");
7. return (refreshToken, account);
8. }
It passes line 3 and 4, so it means it could find the RefreshToken and the related account in line 3, however, later in line 5 I have encountered with the following error:
"message": "Sequence contains no matching element"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.