Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smonn/dotnet-jwt-refresh
https://github.com/smonn/dotnet-jwt-refresh
csharp dotnet example jwt refresh-token
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/smonn/dotnet-jwt-refresh
- Owner: smonn
- Created: 2019-06-27T03:01:41.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T01:08:43.000Z (almost 2 years ago)
- Last Synced: 2023-03-11T01:51:53.517Z (almost 2 years ago)
- Topics: csharp, dotnet, example, jwt, refresh-token
- Language: C#
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JWT login with refresh token
Example of a .NET Core Web API using MongoDB with JWT authentication and support for refresh tokens.
## Assumes these unique indexes are created
```javascript
db.getCollection('accounts').createIndex(
{ username: 1 },
{ unique: true, background: true }
);
db.getCollection('accounts').createIndex(
{ email_address: 1 },
{ unique: true, background: true }
);
db.getCollection('refresh_tokens').createIndex(
{ account_id: 1, value: 1 },
{ unique: true, background: true }
);
```## Sample requests
### Create a new account
```http
POST https://localhost:5001/api/accounts
Content-Type: application/json{
"username": "alice",
"password": "t0ps3cret",
"surname": "Albright",
"given_name": "Alice",
"email_address": "[email protected]"
}
```### Login
```http
POST https://localhost:5001/api/login
Content-Type: application/json{
"username": "alice",
"password": "t0ps3cret"
}
```### Refresh access token
```http
POST https://localhost:5001/api/login/refresh
Content-Type: application/json{
"access_token": "",
"refresh_token": ""
}
```### Get account details
```http
GET https://localhost:5001/api/accounts
Authorization: Bearer
```