https://github.com/unicodeveloper/csharp-jwt-authentication-sample
A C# API and GUI that supports username and password authentication with JWTs
https://github.com/unicodeveloper/csharp-jwt-authentication-sample
Last synced: 7 months ago
JSON representation
A C# API and GUI that supports username and password authentication with JWTs
- Host: GitHub
- URL: https://github.com/unicodeveloper/csharp-jwt-authentication-sample
- Owner: unicodeveloper
- License: mit
- Created: 2016-05-22T23:25:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-23T00:16:01.000Z (over 9 years ago)
- Last Synced: 2025-04-30T18:30:16.658Z (9 months ago)
- Language: C#
- Homepage:
- Size: 23.4 KB
- Stars: 34
- Watchers: 6
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Csharp JWT Authentication sample
This is a Csharp Web API that supports username and password authentication with JWTs and has APIs that return user information to the GUI client and vice-versa.
Everything about the Csharp WEB API runs from the `Api` Directory.
The Desktop C# app runs from the `WpfClient` Directory.
## Available APIs
### User APIs
#### POST `/users`
You can do a POST to `/users` to create a new user.
```json
{
"username": "",
"firstname": "",
"middlename": "",
"lastname": "",
"age":
}
```
The body must have:
* `username`: The username
* `password`: The password
It returns the following:
```json
{
"id": "",
"username": "",
"access_token": ""
}
```
That JWT will contain the `id`, `username` and an `expires` indicating when the token will expire.
#### POST `/users/login`
You can do a POST to `/users/login` to log a user in.
The body must have:
* `username`: The username
* `password`: The password
It returns the following:
```json
{
"id": "",
"username": "",
"access_token": ""
}
```
That JWT will contain the `id`, `username` and an `expires` indicating when the token will expire.
### User API
#### GET `/api/users/{id}`
Where `id` is the Id of a user
It returns the complete user information
```json
{
"id": "",
"username": "",
"firstname": "",
"middlename": "",
"lastname": "",
"age":
}
```
The JWT must be sent on the `Authorization` header as follows: `Authorization: `
## Running it
Just clone the repository, and launch the solution in Visual Studio. That's it :).
This project was built using Visual Studio 2015.
## Issue Reporting
If you have found a bug or if you have a feature request, please report them at this repository issues section.
## Author
[Prosper Otemuyiwa](https://twitter.com/unicodeveloper)
## License
This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.