Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ElohimCode/SneakerAPI

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Json Web Token with ASP.NET Core Web API.

The following project demonstrates how to create and use JWT (Json Web Token) in ASP.NET Core Web API.

The step by step video can be found here :
https://www.youtube.com/watch?v=MltKzQpaltk

Description

The API manages a sneaker store, it exposes endpoints for CRUD operations over a Sneaker table.

The endpoints are secure with a JWT.

Setup

Create an empty database

I used SQLExpress in this tutorial.

Clone the repo

git clone https://github.com/techwithpat/SneakerAPI

Update the configuration

In appsettings.Development.json (under appsettings.json) :

Set the connectionstring to the database

 "ConnectionStrings": {
    "SqlConnection": "The Connection string to your database"
  }

Check Jwt setttings

"JwtSettings": {
    "validIssuer": " String that represents a valid issuer [your name for instance]",
    "validAudience": "http://localhost:35464 or the Url of your API [check in Properties/launchSettings.json]",
    "secret": "yoursecret"
  }

Build the solution (Ctrl + Shift + B)

This step should download and install the dependencies.

Apply existing migrations

This step will create all the tables and seed them with some data.

If you use VS, in the package manager console : Update-Database
If you use NET Core CLI : dotnet ef database update

Run the project

Press F5 to launch the API.
First, with your username / password, you should request an authentication token to the endpoint : /api/auth/login.

Then, include the token in your headers for GET and POST operations : Authorization: Bearer eyJhbGc...........

Built With

C#
ASP.NET Core Web API
.NET 5

Author

Patrick Tshibanda

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C# 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.