JWT Refresh Token in ASP.Net Core (a deep dive)

  Рет қаралды 30,973

DotNet Core Central

DotNet Core Central

Күн бұрын

Пікірлер
@DevKumar-nh6vk
@DevKumar-nh6vk Жыл бұрын
For Refresh API, "do we need to pass anything in Header". For me evetime refresh API giving 401. Not able to get what is Wrong. As in Body already passing RefreshCred(jwt token & refreshToken).
@ksdvishnukumar
@ksdvishnukumar 4 жыл бұрын
It really helped me a lot to understand the JWT concepts and to implement the same... Hats off to you to make such a valuable video for better understanding...
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
VISHNU KUMAR thanks! I’m glad the video helped you.
@anshulasati4778
@anshulasati4778 2 жыл бұрын
Hi, why does this code not refresh the expired JWT token.?
@MuhammadKamran-xj6jw
@MuhammadKamran-xj6jw 2 жыл бұрын
Is this sliding token concept?
@eliassal1
@eliassal1 3 жыл бұрын
Again, 2 fantastic , helpful and well explained videos (in spite of the fact that I got lost a little bit between the different objects :-) as this is very new to me ). Just to validate my understanding, so once we call the refresh api, to reauthenticate, 1 hour later, we should use the RefreshToken for reauthentificiation, am I correct or it is the original Jwtoken that will be extended by another hour?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Salam Elias, you are correct, you need to provide the refresh token for refreshing and getting a new token.
@Stuntman5701
@Stuntman5701 3 жыл бұрын
im just kinda confused. why does a jwt token expire that quickly when i could regenerate a new one with the refreshkey anyways? if someone steals my cookies im fucked anyways
@ashokkumarnaralasetti4860
@ashokkumarnaralasetti4860 3 жыл бұрын
I think without refresh key also we can regenerate token right
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@AshokKumar Naralasetti, yes.
@Marv3Lthe1
@Marv3Lthe1 3 жыл бұрын
Why should I use refresh token instead of increasing the timeout of my original JWT token ?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Marv3Lthe1, the reason you don't want to use a longer timeout is that if your token is stolen you will remain vulnerable for a longer time, hence using a refresh token.
@manasmalik9133
@manasmalik9133 2 жыл бұрын
After the expiry of the access token, a new access token is not generated even with the Refresh Token. public AuthResponse Refresh(RefreshCredential refreshCredential) { SecurityToken validatedToken; var tokenHandler = new JwtSecurityTokenHandler(); var principal = tokenHandler.ValidateToken(refreshCredential.AccessToken, new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false }, out validatedToken);
@user-rp9iis1en6h
@user-rp9iis1en6h 2 жыл бұрын
Excellent tutorial boss. Please make a discussion on how to optimize dbcontext and configure connection pooling for entityframework core.
@AzZaph
@AzZaph 3 жыл бұрын
after receiving the refresh token after jwt expires. Which one should be use in the Authorization?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Flote Fuertes, thanks for watching. You should use a refresh token to get the new token only. For authentication, you should use the new token received with the help of a refresh token.
@AzZaph
@AzZaph 3 жыл бұрын
@@DotNetCoreCentral Thank you very informative content
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@@AzZaph you are welcome!
@birendrasahu5777
@birendrasahu5777 4 жыл бұрын
Awesome . Cleared my doubts. Thank you bro 🙏
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Birendra Sahu, thanks for watching!
@boredo7502
@boredo7502 4 жыл бұрын
Do you have Git repo for this? it was a nice video thanks!
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
Yes I have. github.com/choudhurynirjhar/auth-demo
@shreeprasadlohar9564
@shreeprasadlohar9564 2 жыл бұрын
@@DotNetCoreCentral This is supposed tobe added in description. Anyways thanks..🙂🙂
@koushikdas5122
@koushikdas5122 2 жыл бұрын
System.InvalidOperationException: 'Action 'Auth.Demo.Controllers.NameController.Authenticate (Auth.Demo)' has more than one parameter that was specified or inferred as bound from request body. Only one parameter per action may be bound from body. Inspect the following
@koushikdas5122
@koushikdas5122 2 жыл бұрын
Pls sir look into this
@DotNetCoreCentral
@DotNetCoreCentral 2 жыл бұрын
​@@koushikdas5122 can you share your code here, the part where you are getting error
@carecovered1434
@carecovered1434 4 жыл бұрын
In a realistic world, Will user be sending us both JWTToken and Refresh token and on API we need to first check if JWTToken is valid(not expired too) if expired then to use RefreshToken to validate?
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Care Covered, in the real world scenario, ideally the caller should be sending refresh token only when the auth token is expired. And the caller finds it out based on the Auth error response from the service. That is the workflow that is what I have seen normally used.
@anushreedesai7505
@anushreedesai7505 3 жыл бұрын
Can you tell how can we generate JWT token using azure active directory (using client, tenant id etc) ?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Anushree Desai, generating JWT token is similar, but I have dot done it using azure active directory service before, so I cannot tell for sure what goes into it. Once I try it out I can let you know.
@arslansaleem8629
@arslansaleem8629 4 жыл бұрын
please shear the link of other videos you have mention at the start of this video
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Arslan Saleem, all the videos are available on my channel.
@mrjamiebowman
@mrjamiebowman 3 жыл бұрын
Is there a GitHub for this code? Would be helpful.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Jamie Bowman, yes. github.com/choudhurynirjhar/auth-demo
@PankajNikam
@PankajNikam 4 жыл бұрын
Please share the repo in description.
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
It's in here: dotnetcorecentral.com/blog/authentication-handler-in-asp-net-core/ Thanks for watching the video.
@nirajdahal5019
@nirajdahal5019 4 жыл бұрын
Hello sir!! How do we add external login providers like facebook, google, linkedin etc in .net core web api.. for example: How do i add extra login providera like google facebook in this project that you have taught us?
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
Niraj Dahal so if I understand your requirement properly, you want to use Facebook or google etc as oauth provider. It should be similar way using a middleware. I can give it a try in a future video. Thanks
@sukurullasheikh3301
@sukurullasheikh3301 4 жыл бұрын
hello sir do you have git repo please send the project git repo link we need to undestand
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@sukurulla sheikh, here is the repo: github.com/choudhurynirjhar/auth-demo
@shivaprasadmanchala3955
@shivaprasadmanchala3955 4 жыл бұрын
I need to destroy jwt token when user logout...can u please let me sir
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
SHIVA PRASAD MANCHALA on your logout API call you can remove the token from the toke store.
@shivaprasadmanchala3955
@shivaprasadmanchala3955 4 жыл бұрын
Sir if u have repository....can u please share sir
@shivaprasadmanchala3955
@shivaprasadmanchala3955 4 жыл бұрын
Am not saving token in database
@Engineer_With_A_Life
@Engineer_With_A_Life 3 жыл бұрын
@@shivaprasadmanchala3955 you can remove token from the client storage/browser
@umasankar9971
@umasankar9971 2 жыл бұрын
Could you please share the source code for this
@DotNetCoreCentral
@DotNetCoreCentral 2 жыл бұрын
github.com/choudhurynirjhar/auth-demo
@alihaydar3021
@alihaydar3021 3 жыл бұрын
Great job 👍 again)) but I think the expired of refresh token needs to be more than 1 hour this exactly the duty of refresh token but you copy paste the same time if jwt token
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Ali Haydar, thanks for watching! Yes, I copied and pasted without changing just for the interest of time, but yes refresh tokens are usually much longer-lived compared to a normal token.
@vattikiti
@vattikiti 3 жыл бұрын
Can you please give us the link of the source code
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@V VV, thanks for watching! The source code is available in my GitHub report here: github.com/choudhurynirjhar/auth-demo
@ayan-qn9or
@ayan-qn9or 4 жыл бұрын
If you please post a tutorial video on integration testing using key token, when token is generated in different api would be very helpful. Thanks.
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@ayanghosh thanks for watching! Sure I will give it a try.
@ayan-qn9or
@ayan-qn9or 4 жыл бұрын
@@DotNetCoreCentral Thanks.
@Vennix13
@Vennix13 3 жыл бұрын
Hey, really good video, but do you have any source code ? like on github pls ?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Vennicks, thanks for watching! Here is the repo link: github.com/choudhurynirjhar/auth-demo
@Vennix13
@Vennix13 3 жыл бұрын
@@DotNetCoreCentral thanks a lot !
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@@Vennix13 you are welcome!
@techbuzz3869
@techbuzz3869 4 жыл бұрын
Plz explain .net core project structure and easy to code tips
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
tech buzz I’m not sure I understand completely what are you looking for. Can you please elaborate?
@techbuzz3869
@techbuzz3869 4 жыл бұрын
@@DotNetCoreCentral .net core basic project folder, which files will use for what
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@@techbuzz3869 Ok, I will make a video in the future for that. Thanks for the feedback
@rahuljadhav6022
@rahuljadhav6022 3 жыл бұрын
Thank you Brother....!
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Rahul jadhav, thanks for watching!
@unknown3164
@unknown3164 4 жыл бұрын
link to the repository github.com/choudhurynirjhar/auth-demo
@shuhaib864
@shuhaib864 4 жыл бұрын
Very nice video. Thanks 🙏 Can you please try to do a video about Open ID connect using identity server 4?
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Muhammed Shuhaib, I will put it in my queue, thanks!
@PAJANI1910
@PAJANI1910 3 жыл бұрын
i followed your tutorial, but the token expiry is not working.. i created the token for 2 minutes, but my token is working more than 2 minutes. Then i go through some other videos. x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secreteKey)), ValidateLifetime = true, ValidateIssuer = false, ValidateAudience=false, ClockSkew= TimeSpan.Zero };, in that they used ClockSkew property for token expiry. after i put ClockSkew , my token is not working more than two minutes.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Pajani Arjunan, I will verify and let you know.
ASP.NET Core Authentication with Custom Handler
20:36
DotNet Core Central
Рет қаралды 21 М.
ASP.NET Core Authentication with JWT  (JSON Web Token)
26:09
DotNet Core Central
Рет қаралды 163 М.
Как Ходили родители в ШКОЛУ!
0:49
Family Box
Рет қаралды 2,3 МЛН
Жездуха 42-серия
29:26
Million Show
Рет қаралды 2,6 МЛН
Ozoda - Alamlar (Official Video 2023)
6:22
Ozoda Official
Рет қаралды 10 МЛН
Policy-based Authorization in ASP.Net Core (with Custom Authorization Handler)
19:37
ASP.NET Core Web API + Entity Framework Core : JWT Authorization - EP08
18:00
CuriousDrive: Solve Coding Problems & Win Prizes!
Рет қаралды 41 М.
Clean Architecture with ASP.NET Core 6
29:58
dotnet
Рет қаралды 390 М.
What is a Webhook? [.NET/C# Implementation]
15:23
DotNet Core Central
Рет қаралды 22 М.
Refresh JWT with Refresh Tokens  in Asp Net Core 5 Rest API  Step by Step
1:06:16
How to secure Web API in .NET Core using JWT Token
32:41
the IT videos
Рет қаралды 40 М.
Asp Net Core 5 Rest API Authentication with JWT Step by Step
1:18:32
Mohamad Lawand
Рет қаралды 61 М.
Authentication between Microservices (HTTP and reactive microservices)
11:40
Как Ходили родители в ШКОЛУ!
0:49
Family Box
Рет қаралды 2,3 МЛН