Тёмный

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

Manoj Deshwal
Подписаться 17 тыс.
Просмотров 70 тыс.
50% 1

JSON Web Tokens (JWT) in .NET 6 Web API 🔒 - User Registration / Login / Authentication
In this tutorial, we will discuss about the implementation of JWT authentication in asp.net core 6.0 with example.
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",
"iss": "provider.domain.com/",
"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
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTIzNDU2Nzg5LCJuYW1lIjoiSm9zZXBoIn0.OpOSSw7e485LOP5PrzScxHb7SR6sAOMRckfFwi4rp7o
Tools Used: Visual Studio 2022, Swagger and Postman
☕ Buy me a Coffee (Channel Support through Donation)
www.buymeacoffee.com/manojdes...
📻 Recommended Courses
➤ React Ecommerce Tutorial : • React Ecommerce
➤ React JS Tutorial : • Reactjs
➤ React Router Tutorial : • React Router Tutorial ...
➤ Convert Html Template in Reactjs : • how to convert html te...
➤ ASP.Net WEB API Tutorial : • ASP.NET Web API tutori...
➤ SQL SERVER Tutorial : • SQL Server Tutorial Fo...
➤ HTML Crash Course: • HTML Crash Course For ...
➤ Payment Gateway Integration : • CCavenue Payment Gatew...
➤ WEB API With SQL SERVER : • ASP NET Web API with S...
Subscribe to this channel
➤ bit.ly/2IaMZUr
Must buy Programming Laptops :
amzn.to/3AlLH03
amzn.to/3QQrgiz
amzn.to/3RaqBIQ
amzn.to/3R1EmJS
amzn.to/3QHU9gZ
amzn.to/3QNcAkk
amzn.to/3QKtzno
amzn.to/3dTMbmm
amzn.to/3dQJ7aG
Share, Support, Subscribe Now :
RU-vid 🎥 : / manojdeshwal
Instagram 📷 : / openprogrammer
Twitter 🐦 : / openprogrammer
Facebook 👍 : / openprogrammer
Website 🌐 : www.connectedprogrammer.com/
⭐️Tags : ⭐️
#JWTToken
#.netcoretoken
#.netcorewebapitoken
⭐️ Your Queries : ⭐️
How to setup JWT authorization in asp.net core 6 with swagger in hindi || Jwt authorization with swagger in hindi || JWT atuhentication in hindi ||
JWT authentication in hindi with swagger || asp.net core 6 version jwt authorization token with swagger ||
JWT Authentication in asp.net core 6.0 with swagger Enable JWT authentication enable in swagger JSON Web Token Introduction ||
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# ||
Implementing JWT authentication in Asp.net WebApi || Implementing JWT Authentication in ASP.NET Core 6 ||
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 ||
JWT Bearer token using ApiKeyScheme || JWT Authorization in Swagger || asp.net core 6 version token based authentication ||
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
asp.net core authentication
asp.net core 7 authentication
asp.net core jwt
asp.net core token authentication
json web token
json web token authentication
Thanks for watching. 😊😊 🙏🙏

Наука

Опубликовано:

 

5 фев 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 80   
@thamotharan-xl8ce
@thamotharan-xl8ce 9 месяцев назад
Thank you Bro !!! simple and easy way to understand
@thebrook2024
@thebrook2024 5 месяцев назад
very well explained. Thank you Sir.
@camscott3013
@camscott3013 3 месяца назад
Simple video and explanation. Thanks.
@srinivasanjayamohan8177
@srinivasanjayamohan8177 3 месяца назад
very clear explanation Thanks a lot Manoj!!
@DeepakSingh-hf4dx
@DeepakSingh-hf4dx Месяц назад
Finally the best video I got about JWT. Their a lot of confusion before . Thank you a lot
@ManojDeshwal
@ManojDeshwal Месяц назад
Thanks
@anjithhanumandla2764
@anjithhanumandla2764 27 дней назад
very nice video, and detailed explanation.. superb
@kartikmondal4933
@kartikmondal4933 11 месяцев назад
Thank you so much, sir. This video helps me a lot.
@ManojDeshwal
@ManojDeshwal 11 месяцев назад
Hi, welcome to my channel and thanks for the comment. For any queries, kindly ping me on WhatsApp +91 8826791246 or connect on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@chandankarmakar6651
@chandankarmakar6651 10 месяцев назад
Thank you, this tutorial helped me lot!
@ManojDeshwal
@ManojDeshwal 9 месяцев назад
Hi, welcome to my channel and thanks for the comment. Kindly connect on WhatsApp +91 8826791246 or on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@manognyadasika6918
@manognyadasika6918 3 месяца назад
all thanksss tooo youuu bhaiayyaa... cannt sayyy it helpeeddd a lotttt .... u r the besttttt
@Guru83591
@Guru83591 Год назад
Thankyou so much sir, for making this video. this video more help to me.
@ManojDeshwal
@ManojDeshwal Год назад
Hi, welcome to my channel and thanks for the comment. Kindly follow me on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@user-in2qu8es7w
@user-in2qu8es7w 8 месяцев назад
Thank you, you are the best ❤❤
@sajjadhusain8457
@sajjadhusain8457 6 месяцев назад
thank you so much brother god bless you !!!!!!!!!!!!
@muhammadsalman6768
@muhammadsalman6768 Месяц назад
v good manooj
@Venkatesh_Averi
@Venkatesh_Averi Год назад
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
@parth7450
@parth7450 11 месяцев назад
Very useful
@rasikasamith
@rasikasamith Месяц назад
Excellent video. Thanks a lot.
@ManojDeshwal
@ManojDeshwal Месяц назад
You are welcome!
@playerviii
@playerviii Месяц назад
Very clear 👏🏽🇿🇦 Thanks
@ManojDeshwal
@ManojDeshwal Месяц назад
You’re welcome 😊
@Gauravkumar-jm4ve
@Gauravkumar-jm4ve 5 месяцев назад
very good explanation , subscribed! thank u , and pls keep sharing more
@sureshthaduri6275
@sureshthaduri6275 3 месяца назад
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?
@debasispanda7322
@debasispanda7322 Год назад
Thanks sir for this
@ManojDeshwal
@ManojDeshwal Год назад
Hi, welcome to my channel and thanks for the comment. Kindly connect and follow on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@JazilNauman
@JazilNauman Месяц назад
Very Simple and Easy.
@ManojDeshwal
@ManojDeshwal Месяц назад
Thank you 😊
@ComeOnJunaid
@ComeOnJunaid 2 месяца назад
great
@gopslogsss
@gopslogsss 3 месяца назад
Thanks
@nagarajperumal1681
@nagarajperumal1681 Месяц назад
Why do we need to give same value for issuer and audience?
@ilkinhamid1072
@ilkinhamid1072 5 месяцев назад
thanks
@nangdalet5994
@nangdalet5994 Год назад
Can you demo follow this video using dynamic user with database and using store procedure
@ManojDeshwal
@ManojDeshwal Год назад
Hi, welcome to my channel and thanks for the comment. Could you connect on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@rishi_always_kushi
@rishi_always_kushi 6 месяцев назад
@KundanKumar-lr2vh
@KundanKumar-lr2vh Месяц назад
resolved
@premkumarmanjhi6806
@premkumarmanjhi6806 6 месяцев назад
Very useful 🙏🙏
@user-rd4oo1jg5g
@user-rd4oo1jg5g 9 месяцев назад
What is the difference between Claim and Signature? what does each one reference?
@ManojDeshwal
@ManojDeshwal 9 месяцев назад
Hi, welcome to my channel and thanks for the comment. Kindly connect on WhatsApp +91 8826791246 or on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@virendras7554
@virendras7554 Год назад
What happens when token gets expired? will user need to re send the credentials?
@ManojDeshwal
@ManojDeshwal Год назад
Hi Virendra, welcome to my channel and thanks for the comment. Yes, you are right. Once the token expires then the user has to regenerate the token in order to access the APIs. For any other query kindly follow and connect with me on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@mohammedmubashshirkhazi5611
@mohammedmubashshirkhazi5611 2 месяца назад
Why did you use GenerateToken(Users users) if users is not used in this method?
@theos9202
@theos9202 2 месяца назад
I think the reason why Users were added in the parameters would be in order to create the claims object. Typically the claims object holds some identifiers , such as username, those claims would then be baked into the payload section of the token. The implementation would go like something along these lines: private string GenerateToken(User user) { List myClaims = new List { new Claim(ClaimTypes.Name, user.Username) }; var sercurityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(config["Jwt:Key"]!)); var credentials = new SigningCredentials(sercurityKey, SecurityAlgorithms.HmacSha256); var token = new JwtSecurityToken( config["Jwt:Issuer"], config["Jwt:Audience"], claims: myClaims, expires: DateTime.Now.AddMinutes(15), signingCredentials: credentials); return new JwtSecurityTokenHandler().WriteToken(token); }
@aanandkumar8824
@aanandkumar8824 8 месяцев назад
if i change my username or password then how login
@SomethingSpiritual
@SomethingSpiritual Год назад
Hi Manoj, token expiration not working. I have put 1 min but after 1 min its not expiring. thanks for this video.
@ManojDeshwal
@ManojDeshwal Год назад
Hi, welcome to my channel and thanks for the comment. Kindly connect and follow on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@SomethingSpiritual
@SomethingSpiritual Год назад
@@ManojDeshwal ok thanks
@jaidakhatoon1054
@jaidakhatoon1054 7 месяцев назад
How to add sql database in this
@AamJankariByYadav
@AamJankariByYadav Год назад
Sir please make this video with entity framework .
@ManojDeshwal
@ManojDeshwal Год назад
Hi Rahul, welcome to my channel and thanks for the comment. I will try to create the same soon if you are looking for some customized application then kindly connect with me on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@tembelninja3696
@tembelninja3696 Месяц назад
why did you uncheck https
@Venkatesh_Averi
@Venkatesh_Averi 11 месяцев назад
Thankyou so much bro,if possible can you provide the github link of this bro
@ManojDeshwal
@ManojDeshwal 9 месяцев назад
Hi, welcome to my channel and thanks for the comment. Kindly connect on WhatsApp +91 8826791246 or on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@Pooja-qo7wm
@Pooja-qo7wm Год назад
How to do this with db connection
@ManojDeshwal
@ManojDeshwal 11 месяцев назад
Hi, welcome to my channel and thanks for the comment. For any queries, kindly ping me on WhatsApp +91 8826791246 or connect on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@jayantverma4639
@jayantverma4639 Год назад
how to add sql database in this ?
@ManojDeshwal
@ManojDeshwal Год назад
Hi, welcome to my channel and thanks for the comment. Kindly connect on WhatsApp +91 88267 91246 or on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍.
@prakashm7875
@prakashm7875 Год назад
At 9.18 how to give the website name
@ManojDeshwal
@ManojDeshwal 11 месяцев назад
Hi, welcome to my channel and thanks for the comment. For any queries, kindly ping me on WhatsApp +91 8826791246 or connect on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@user-qe3qe6er2q
@user-qe3qe6er2q 9 месяцев назад
how we can set up swagger ?
@ManojDeshwal
@ManojDeshwal 9 месяцев назад
Hi, welcome to my channel and thanks for the comment. Kindly connect on WhatsApp +91 8826791246 or on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@SSSALLJOBSPORTAL
@SSSALLJOBSPORTAL 5 месяцев назад
it will come by default !!
@user-ij6ei2sf9i
@user-ij6ei2sf9i 11 месяцев назад
What if I create token with one user and use it for another user how to make sure tokern is passed by the user that created it.
@amritnepal14
@amritnepal14 11 месяцев назад
tokens are used for authentication.. you should use authorization also for what you are saying
@user-ij6ei2sf9i
@user-ij6ei2sf9i 11 месяцев назад
?
@ankurkatiyar07
@ankurkatiyar07 9 месяцев назад
JWT tokens generally stored in httponly cookie to make it secure, what you are saying like sharing the user name and password with other users... Think about it
@SSSALLJOBSPORTAL
@SSSALLJOBSPORTAL 5 месяцев назад
think in real time case, for ex: there is an app which needs user id and password from the user, once user entered those credentials, our api what it will do is it will validate the credentials from database end. If user credentials are existed it will generate token and it will add the token into header and it will pass this client app (UI), once user is authenticated, next time when user wants to access the other controller/api , as in http header will get the token like how he passed the token from postman, in the same way from client app also, we will get the token and it can access the api. And you told that Can i use the other user's token to another user login, How it will workout!!! either you have to sign out or you have to log in from one more client app which is from other device. Please excuse my english grammer mistakes!!😀
@SSSALLJOBSPORTAL
@SSSALLJOBSPORTAL 5 месяцев назад
@@amritnepal14 both are quite different as per my knowledge, in this video, buddy explained about both the cases 1. Authentication ( when user trying login , api should validate the user credentials and generate a token on successful login. ) 2. Authorization (when user trying to access the api which is decorated with authorize attribute, in this case we are able to access the api by passing the token as authorization. I hope you understood!!!
@Javedinsha
@Javedinsha Год назад
Bhai mujhe aapse paid class Leni hai
@ManojDeshwal
@ManojDeshwal Год назад
Hi Javed, welcome to my channel and thanks for the comment. Kindly connect on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
@KundanKumar-lr2vh
@KundanKumar-lr2vh Месяц назад
Hi Bro, It's failed to get load swagger in .net 8 "giving internal server error"
@user-oj5hd9km5n
@user-oj5hd9km5n 3 месяца назад
Thanks manoj
@amiruddinsamalayawala7179
@amiruddinsamalayawala7179 5 месяцев назад
It Showing Error while Installing the package, how can i resolve this Error: Could not install package 'Microsoft.AspNetCore.Authentication.JwtBearer 8.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
@SSSALLJOBSPORTAL
@SSSALLJOBSPORTAL 5 месяцев назад
in that case, you can choose the package of version 6.0.0, It will work!!!
@hz73219
@hz73219 10 месяцев назад
Thank you !!! simple and easy to understand
@ManojDeshwal
@ManojDeshwal 9 месяцев назад
Hi, welcome to my channel and thanks for the comment. Kindly connect on WhatsApp +91 8826791246 or on Instagram @openprogrammer is my Instagram handle. Keep learning and supporting 👍
Далее
А что если не умеешь играть?🥲
00:46
What Is JWT and Why Should You Use JWT
14:53
Просмотров 1,1 млн
Why is JWT popular?
5:14
Просмотров 275 тыс.
iPhone 15 Pro vs Samsung s24🤣 #shorts
0:10
Просмотров 12 млн
Mac Mini Собираем из двух один!
0:59