JSON Web Tokens (JWT) in .NET 6 Web API 🔒 - User Registration / Login / Authentication

preview_player
Показать описание
JSON Web Tokens (JWT) in .NET 6 Web API 🔒 - User Registration / Login / Authentication

A JSON web token(JWT) is JSON Object which is used to securely transfer information over the web(between two parties). It can be used for an authentication system and can also be used for information exchange. The token is mainly composed of header, payload, signature. These three parts are separated by dots(.)

Header
A header in a JWT is mostly used to describe the cryptographic operations applied to the JWT like signing/decryption technique used on it. It can also contain the data about the media/content type of the information we are sending.

{
"typ":"JWT",
"alg":"HS256"
}

Payload
The payload is the part of the JWT where all the user data is actually added. This data is also referred to as the ‘claims’ of the JWT. This information is readable by anyone so it is always advised to not put any confidential information in here.

{
"userId":"b07f85be-45da",
"sub": "auth/some-hash-here",
"exp": 153452683
}

Signature
This is the third part of JWT and used to verify the authenticity of token. BASE64URL encoded header and payload are joined together with dot(.) and it is then hashed using the hashing algorithm defined in a header with a secret key. T

JWT Example :

header:

{
"alg" : "HS256",

"typ" : "JWT"
}

Payload:

{
"id" : 123456789,

"name" : "Manoj"
}

Secret: manojdeshwal
JSON Web Token

Tools Used: Visual Studio 2022, Swagger and Postman

☕ Buy me a Coffee (Channel Support through Donation)

📻 Recommended Courses

Subscribe to this channel

Must buy Programming Laptops :

Share, Support, Subscribe Now :

⭐️Tags : ⭐️

#JWTToken
#.netcoretoken
#.netcorewebapitoken

⭐️ Your Queries : ⭐️

How does JWT authentication work? || What is JWT authentication in REST API? || Is JWT better than session? || Is JWT the same as OAuth? ||
JWT Authentication || JWT authentication: Best practices and when to use it || What Is JWT? How Does It Work? ||
JWT Token Authentication And Authorizations In .Net Core 6.0 || Is there any JSON Web Token (JWT) example in C# ||
Jwt .Net 6 , a JWT (JSON Web Token) implementation for .NET core 6 || Create and Sign a JSON Web Token (JWT) with C# and .Net core 6 ||
how to access the api with jwt token .net 6 || NET 6.0 - JWT Authentication Tutorial with Example API ||
How to implement JWT autentication in ASP Core Net 6 || ‍ Authentication And Authorization In .NET Core Web API
token authentication
token authentication explained
token authentication c#
token authentication vs jwt
token authentication postman
jwt
jwt token
jwt authentication
json web token
json web token authentication

Thanks for watching. 😊😊 🙏🙏
Рекомендации по теме
Комментарии
Автор

Great explanation ❤ Finally I learned how to use auth middleware with JWT Token ✌️👏🏻

Saurabh.K
Автор

Finally the best video I got about JWT. Their a lot of confusion before . Thank you a lot

DeepakSingh-hfdx
Автор

very nice video, and detailed explanation.. superb

anjithhanumandla
Автор

very clear explanation Thanks a lot Manoj!!

srinivasanjayamohan
Автор

Everything is fine but in real time jwt token is generated in one api, and authorization done is another api, how to perform this sir, please reply me

Venkatesh_Averi
Автор

all thanksss tooo youuu bhaiayyaa... cannt sayyy it helpeeddd a lotttt .... u r the

manognyadasika
Автор

after searching many days i found good video on jwt token.

i have confusion:
1) you added issuer, audience, Key in appsetting.json file. when i build where can i get. can i use randomly?
2) if i did not use one mthod with authorize filter can i access directly without token or authentication/login?
3) why you used postman here. can not use swgger all time?

can you please explain?

sureshthaduri
Автор

Thank you Bro !!! simple and easy way to understand

thamotharan-xlce
Автор

Why did you use GenerateToken(Users users) if users is not used in this method?

mohammedmubashshirkhazi
Автор

Thankyou so much sir, for making this video. this video more help to me.

Guru
Автор

Thank you so much, sir. This video helps me a lot.

kartikmondal
Автор

thank you so much brother god bless you

sajjadhusain
Автор

very good explanation, subscribed! thank u, and pls keep sharing more

Gauravkumar-jmve
Автор

Why do we need to give same value for issuer and audience?

nagarajperumal
Автор

Thank you, this tutorial helped me lot!

chandankarmakar
Автор

Hi Manoj, token expiration not working. I have put 1 min but after 1 min its not expiring. thanks for this video.

SomethingSpiritual
Автор

Sir please make this video with entity framework .

AamJankariByYadav
Автор

What is the difference between Claim and Signature? what does each one reference?

rdoojgg
Автор

Can you demo follow this video using dynamic user with database and using store procedure

nangdalet
Автор

if i change my username or password then how login

aanandkumar