ASP.NET CORE Web API - JWT Authentication (Refresh Token + Role Based + Entity Framework ) | Swagger

  Рет қаралды 44,841

Nihira Techiees

Nihira Techiees

Күн бұрын

#asp.netcore #webapiauthentication #jwt
This video explains complete feature of .NET CORE Web API with Authentication
Below Topics are covered
===========================
1, Create Web API using .NET CORE
2, ADD Entity Framework
3, Implement JWT Authentication
1, Refresh Token
2, Role Based Authentication
4, Implement Swagger for API
5, Enable CORS
6, Deployment in IIS Server
7, Test Web API in Postman
GitHub URL - Source
=================
github.com/nih...
GitHub URL - DB Script
===================
github.com/nih...

Пікірлер: 124
@lrl2054
@lrl2054 2 жыл бұрын
Great explanation! Thank you for sharing!
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Thanks for your support
@kgoute5099
@kgoute5099 Жыл бұрын
Awesome Tutorial and Thank you sir
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Glad to hear, welcome
@balakrishnan-gf9rw
@balakrishnan-gf9rw 2 жыл бұрын
Creating new refreshtoken for first time user:- context.Entry(tblRefreshtoken).State = EntityState.Added; context.SaveChanges();
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
👍
@arundeepaktirkey6920
@arundeepaktirkey6920 2 жыл бұрын
@@NihiraTechiees where to write this code? for generating first token.
@janoshollosi9570
@janoshollosi9570 11 ай бұрын
@@arundeepaktirkey6920 RefreshTokenGenerator class -> after tblRefreshtoken creation - it is created but not written to database table
@satheeswaranj6990
@satheeswaranj6990 2 жыл бұрын
Thanks bro.. nice explanation 👌 👍 👏
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Thanks for the feedback
@shakulhameedmaricar8508
@shakulhameedmaricar8508 Жыл бұрын
Thanks a lot. Clear explanation
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Thanks🙏
@sureshl1447
@sureshl1447 2 ай бұрын
not clear explanation...16:11 , what is IOption ? why we are using?
@AniAnil-wf7tx
@AniAnil-wf7tx 2 ай бұрын
Great Explanation!!! and Need DB scripts
@NihiraTechiees
@NihiraTechiees 2 ай бұрын
Db script uploaded in GitHub link available in description
@soundarpandi3628
@soundarpandi3628 Жыл бұрын
Great Explanation Anna Thanks
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Thanks brother 🤝
@amardzanan8255
@amardzanan8255 2 жыл бұрын
Amazing videos. Keep it up !
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Thanks🙏
@AnandRaj-hq4zv
@AnandRaj-hq4zv 2 ай бұрын
Hi sir when I am creating new user and login then it’s not saving refresh in table for new user.
@NihiraTechiees
@NihiraTechiees 2 ай бұрын
Please debug any error while creating new record
@huntspot2346
@huntspot2346 2 жыл бұрын
5:54 How the models folder came ? How you created that?
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
It's created from scaffolding comment. Watch 5:10 to 5:25
@huntspot2346
@huntspot2346 2 жыл бұрын
@@NihiraTechiees i am getting error, scaffolding comment is not running successfully. Scaffold-DbContext "Server=DESKTOP-GRKHDU6; Database=LocalGroup;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer - OutputDir Models
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Did you installed all the packages
@huntspot2346
@huntspot2346 2 жыл бұрын
@@NihiraTechiees Yes i installed
@community7757
@community7757 Жыл бұрын
@@huntspot2346 I've seen a typo error in your code. It's -OutputDir not - OutputDir (space before Output).
@InfinityBoyz_ShanCreations
@InfinityBoyz_ShanCreations Жыл бұрын
Can you please explain what is that folder that you are copying APIcore files into another folder and in last part of video in IIS server website configuration you select that new folder why and what is actually that folder I just created a new folder in my angular aplication folder and pasted it but I get error while hosting on port 84 as you showed?
@NihiraTechiees
@NihiraTechiees Жыл бұрын
If port is already used try other port
@dilshadazam880
@dilshadazam880 9 ай бұрын
There is no startup.cs file in .net 6. How come you have in this video. please help how do I get startup.cs while creating the project
@NihiraTechiees
@NihiraTechiees 9 ай бұрын
This video created 2 years back with dot net core 3. From dotnet 6 onwards there is no startup file. So whatever code we written in startup files it's moved to program.cs file please follow my .NET 7 tutorial it's almost same as .NET 6
@meta6114
@meta6114 2 жыл бұрын
Thanks anna sp based sql next video poduga anna
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Sure
@Xpressk
@Xpressk 2 жыл бұрын
Great video. Thanks. I generated a refresh token, however, my old token is still valid, if i pass that to a post request, I am able to get values. Anything explicitly we need to do to manually expire the old tokens?
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
What is token expiration time?
@Xpressk
@Xpressk 2 жыл бұрын
@@NihiraTechiees 10 mins
@WorldEnder
@WorldEnder Жыл бұрын
@@Xpressk it's probably 10 min + 5 min from the way it expires
@muhdkrd
@muhdkrd 2 жыл бұрын
Hi, Can you create a whole Get, Post, Put, Delete with DataService + Controller with Models Dto & MapToDto All these topics in a single video. Thank you.
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Let me try
@muhdkrd
@muhdkrd 2 жыл бұрын
@@NihiraTechiees I have texted you on google chat. Will you please check?
@pathumlakshan9258
@pathumlakshan9258 10 ай бұрын
My scaffold command is not valid. it gives me an error. how to fix that? Scaffold-DbContext : A positional parameter cannot be found that accepts argument '-'. At line:1 char:1 + Scaffold-DbContext "Server=.\\mssqlserver01; Database=ProductAPI_JWT. ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Scaffold-DbContext], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Scaffold-DbContext this is the error i got
@NihiraTechiees
@NihiraTechiees 10 ай бұрын
Send me mail with details... Will repond tonight
@pramodanachimath5081
@pramodanachimath5081 Жыл бұрын
Sir can I get to know how you have inserted values for usercred ,bcz I am getting unauthorized everytime
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Do you have database setup?
@basantkumarmandal3610
@basantkumarmandal3610 2 жыл бұрын
I have created Usercontroller using controller with action And Entity framework , and it is not working so please give some guidence
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
What error is coming
@sunilshinde233
@sunilshinde233 Жыл бұрын
thank you for sharing . But i see expiration time is not accurate, i see some time zone issue, how to fix that.
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Which time zone you facing problem
@sunilshinde233
@sunilshinde233 Жыл бұрын
I see expiration time was not found correct , i used UTC for token expiration , then worked expiration time accurately.
@GovindSingh-em1iy
@GovindSingh-em1iy Жыл бұрын
InvalidOperationException: Unable to resolve service for type 'Learn_DbAPI.Models.CustomerContext' while attempting to activate 'Learn_DbAPI.Controllers.CustomerController'.
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Please do register your db context (customer context) in program.cs file
@GovindSingh-em1iy
@GovindSingh-em1iy Жыл бұрын
@@NihiraTechiees Thank you very much Sir. By adding this below code in program.cs, it resolved.... builder.Services.AddDbContext(options => { options.UseSqlServer(builder.Configuration.GetConnectionString("constring")); }); Thanks Again Sir.
@jaypatadia3744
@jaypatadia3744 2 жыл бұрын
How to pass dynamic roles in controller for eg you have passed admin role in the controller
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Actually I am passing token only, when I am creating token I included roles in token. Token creating we are checking credentials same we can get roles from database
@divyapant3748
@divyapant3748 Жыл бұрын
Hi, can I get the database queries for the tables. And also I guess I don't have the version in which there is any Startup file.
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Dot Net core version 5 & above don't have startup file... Startup file codes also moved to program.cs
@hamletmendez
@hamletmendez Жыл бұрын
Can you tell me the framework version in which the tutorial was made?
@NihiraTechiees
@NihiraTechiees Жыл бұрын
This video I used dot net core 3.0
@TariqulIslam-k4v
@TariqulIslam-k4v 10 ай бұрын
Great content ! Can you explain how can i invalidate or revoke the token on against with my signout functionality. Yes i know that JWT has no option to cancel the token but is it possible any way to invalidate the token ?
@NihiraTechiees
@NihiraTechiees 10 ай бұрын
We can write custom logics like... Always store jwt tolen in database once sign out make sure we need to remove from database. Token validation time also need to check database.... But it's not good practice Since you have requirement like this then we can do
@bhuvaneshharikrishnan3617
@bhuvaneshharikrishnan3617 2 жыл бұрын
Well explained. Need Db queries.Thanks
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Your email id please
@gladisxavier2430
@gladisxavier2430 2 жыл бұрын
token post method shown 200 ok but key not generated in body pls solve this bro
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
First debug, then cross check with GitHub source. I hope you not returned
@jhonnidarshan3094
@jhonnidarshan3094 Жыл бұрын
Hey bro ! can you make a front part as well in angular for the authentication?
@NihiraTechiees
@NihiraTechiees Жыл бұрын
kzbin.info/aero/PLfyWdpsiUiPD7kYHujLg3Vl6GV69yQPgD
@jhonnidarshan3094
@jhonnidarshan3094 Жыл бұрын
@@NihiraTechiees thank you
@diligencehumility6971
@diligencehumility6971 2 жыл бұрын
Please... the bird on the background, or what it is... driving me nuts. Buy good video otherwise
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Yes it's birds only. Buy good video Otherwise what ?
@iram9465
@iram9465 Жыл бұрын
@@NihiraTechiees Buy seems to be a typo for the word 'but'. But good video otherwise. Honestly the cheerful birds are nice but really bothered me to throughout the video. Thank you for the video.
@diligencehumility6971
@diligencehumility6971 2 жыл бұрын
Why are you installing 3.0.1 version of EF Core and EF Core Tools? Instead of the newest version? 6.0
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Latest version is not suitable for .NET Core 3.01
@meta6114
@meta6114 2 жыл бұрын
Hai ji Unga code ah github la update pana naila iruku.
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
ok
@muneeswarreddy1129
@muneeswarreddy1129 Жыл бұрын
Sir How we are storing token in database
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Refresh token only we are storing in database using entity framework. Jwt token we are just generating and returning
@santoshernandez9663
@santoshernandez9663 Жыл бұрын
Hi, where is the part for the registration?
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Register I have not created video but added code, please check link in description for source . Register method available in user controller
@AyatSoft
@AyatSoft Жыл бұрын
Great Video! Can you Share DB Queries..
@NihiraTechiees
@NihiraTechiees Жыл бұрын
please check here github.com/nihira2020/Database/blob/main/Learn_DB_script.sql
@AyatSoft
@AyatSoft Жыл бұрын
@@NihiraTechiees Thanks for sharing
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Welcome
@AshishKumar-ep4ow
@AshishKumar-ep4ow 2 жыл бұрын
Hello Sir, Can you please provide the database table queries?
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Send me mail
@sprajpure
@sprajpure 2 жыл бұрын
Can you please upload the database schema of this project on github
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Sure, let you know shortly
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
github.com/nihira2020/Database/blob/main/Learn_DB_script.sql
@thaerkilani5804
@thaerkilani5804 Жыл бұрын
can u create this with identity server? thank u
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Will do in future
@Iamgogetartist
@Iamgogetartist 2 жыл бұрын
Good Explanation Can you provide me the Soure code
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Please check description source code link is available
@danishkhan2897
@danishkhan2897 2 жыл бұрын
Can you please provide SQL Queries
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Please send me request mail
@rakesht7004
@rakesht7004 2 жыл бұрын
Could you please provide me the database of this project too
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Send me mail, I will provide on the same
@manhlong6335
@manhlong6335 Жыл бұрын
I want to file script database. Do you send me file script database?
@NihiraTechiees
@NihiraTechiees Жыл бұрын
It's available in my github repos. Repo name database & filename is learn_db_script.sql
@manhlong6335
@manhlong6335 Жыл бұрын
@@NihiraTechiees thank you brother
@manhlong6335
@manhlong6335 Жыл бұрын
@@NihiraTechiees i have'nt see file learn_db_script.sql
@NihiraTechiees
@NihiraTechiees Жыл бұрын
github.com/nihira2020/Database/blob/8f58d84d71c81900c59c69c2630eb89803224137/Learn_DB_script.sql
@NihiraTechiees
@NihiraTechiees Жыл бұрын
Can you check this link
@muhdkrd
@muhdkrd 2 жыл бұрын
Hi please provide me database tables queries. Thank you.
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Your mail id?
@muhdkrd
@muhdkrd 2 жыл бұрын
comment gets deleted if I use gmail in the end. Thank you.
@muhdkrd
@muhdkrd 2 жыл бұрын
@@NihiraTechiees waiting, please. Thank you.
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Check your mail
@rosiealexsander6607
@rosiealexsander6607 2 жыл бұрын
@@NihiraTechiees hiii could you please give me database query ?
@ajithaji6793
@ajithaji6793 2 жыл бұрын
Hi bro i need database tables queries.
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Send me your email id
@ajithaji6793
@ajithaji6793 2 жыл бұрын
Did you get the my email id .
@ajithaji6793
@ajithaji6793 2 жыл бұрын
@@NihiraTechiees bro I need sql code
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
I don't receive your email, please send me a mail @ nihiratechiees@gmail.com
@ajithaji6793
@ajithaji6793 2 жыл бұрын
Thanks bro
@meta6114
@meta6114 2 жыл бұрын
Entha code ah github la update panido video kila kuduga ji
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
github.com/nihira2020/DotNETCORE_API_JWTToken
@meta6114
@meta6114 2 жыл бұрын
@@NihiraTechiees thank dude🙂
@jayakumar2927
@jayakumar2927 2 жыл бұрын
@@NihiraTechiees This page isn’t working shows
@jayakumar2927
@jayakumar2927 2 жыл бұрын
@@NihiraTechiees This page isn’t working shows
@mayoonava4938
@mayoonava4938 2 жыл бұрын
Great explanation! Thank you for sharing!
@NihiraTechiees
@NihiraTechiees 2 жыл бұрын
Glad to hear
ASP.NET Core JWT Authentication and role-based authorization
39:17
The joker favorite#joker  #shorts
00:15
Untitled Joker
Рет қаралды 10 МЛН
Win This Dodgeball Game or DIE…
00:36
Alan Chikin Chow
Рет қаралды 24 МЛН
Swagger is Going Away in .NET 9!
10:48
Nick Chapsas
Рет қаралды 95 М.
What Is JWT and Why Should You Use JWT
14:53
Web Dev Simplified
Рет қаралды 1,2 МЛН
Building a .NET 6 API Using TDD
1:38:59
Wes Doyle
Рет қаралды 145 М.
.NET Framework vs .NET Core vs .NET vs .NET Standard vs C#
25:14
IAmTimCorey
Рет қаралды 554 М.
Turns out REST APIs weren't the answer (and that's OK!)
10:38
Dylan Beattie
Рет қаралды 158 М.
Difference Between REST API vs Web API vs SOAP API Explained
7:24
Learn with Whiteboard
Рет қаралды 207 М.
Difference between cookies, session and tokens
11:53
Valentin Despa
Рет қаралды 630 М.