.NET 7 Web API 🔒 Role-Based Authorization with JSON Web Tokens (JWT) & the dotnet user-jwts CLI

  Рет қаралды 43,327

Patrick God

Patrick God

Күн бұрын

Пікірлер: 42
@PatrickGod
@PatrickGod Жыл бұрын
🚀 Join the .NET Web Academy with a 30% discount - closing soon! 👉 www.dotnetwebacademy.com/courses/academy?coupon=dnwas23yt
@joaogabrielv.m328
@joaogabrielv.m328 Жыл бұрын
Great video, Patrick! Any chances to have a video teaching the basics of Identity Framework with MVC?
@akbaralimajeed
@akbaralimajeed Жыл бұрын
Hi, if anyone gets the error while create jwt token as "dotnet : No project found at `-p|--project` path or current directory.", make sure you run above command inside the project folder not on the root folder (solution level), it requires to be in the same project file folder; hope this helps ):
@nguyenthanhat6122
@nguyenthanhat6122 Жыл бұрын
thank you so much
@UserUser5-c4c
@UserUser5-c4c Жыл бұрын
Your videos are 5-stars :) Just a hint about issue with invalid SignInKey while using user-jwts generated token (20:36 in video), in the application instead of decoding key into UTF8 it is required to docode it as base64 and it will work.
@jzn007x
@jzn007x Жыл бұрын
Could you give us the example?
@UserUser5-c4c
@UserUser5-c4c Жыл бұрын
@@jzn007x here is raw example: in Patrick's example in program.cs file, under AddAuthentication modify part where he is declaring IssuerSignInKey with => new SymmetricSecurityKey(Convert.FromBase64String("HereYouShouldPasteSigningKeyGeneratedByUseJwts"))
@ynkdqe
@ynkdqe Жыл бұрын
Your tutorials are very helpful and easy to understand
@PatrickGod
@PatrickGod Жыл бұрын
Glad you think so! Thanks so much!
@SportProgramming
@SportProgramming Жыл бұрын
I cannot get it to accept the token, no matter what i do in jwt if i enable the secret code.
@abdulhakimawad
@abdulhakimawad Жыл бұрын
Id do every thing like you, but the lock in the weather methode stills opened & return unauthorized error, why??
@thomasdevelopment
@thomasdevelopment Жыл бұрын
Once a user is logged in how is the token being stored to maintain the user state?
@ivandrofly
@ivandrofly Жыл бұрын
Nice... I didn't know u could gen keg with dotnet command
@elishamisoi
@elishamisoi 11 ай бұрын
Thank you so much Patrick.
@augustusdevree5434
@augustusdevree5434 Жыл бұрын
Is the signiture key was not found [@20:32] not the result of confronting the the token generated by the CLI with it's signing key "6ffvSugNwB6..." [@20:12] and your signing key specified in AppSettings:Token key "my top secret key" [@19:35]?
@Klayperson
@Klayperson Жыл бұрын
that's what i was thinking. for a second he did paste in the configuration path to the key from the CLI, but he didn't save it that way
@ArmedMob
@ArmedMob Жыл бұрын
@@Klayperson Threw me for a loop in my app as I did not see him not save that. I did find as long as both are the same it works.
@Avster9
@Avster9 Жыл бұрын
Great video! Can you make a video with simple CQRS implementation?
@BlackGrinch-dl9qz
@BlackGrinch-dl9qz Жыл бұрын
Awesome buddy!
@thegamer1599
@thegamer1599 Жыл бұрын
can someone tell me what patrick did at 11:04 coz im not using swagger from start, are there any other possible ways to do that?
@jesusnaun1981
@jesusnaun1981 Жыл бұрын
Someone help me please. when I execute dotnet user-jwts create in console, this show me that error: dotnet : No project found at `-p|--project` path or current directory. At line:1 char:1 + dotnet user-jwts create + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (No project foun...rent directory.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
@akbaralimajeed
@akbaralimajeed Жыл бұрын
Hi, make sure you run above command inside the project folder not on the root folder (solution level), it requires to be in the same project file folder; hope this helps ):
@SANGCAOHOAI
@SANGCAOHOAI Жыл бұрын
"cd" to the folder which have Container foler there
@ViktorTy
@ViktorTy Жыл бұрын
I just watched and implemented the .NET 6 Web API Authorization and now I see there is a new one haha what are the chances
@ndrcreates_per
@ndrcreates_per Жыл бұрын
I've done all of the auth completly in my app. my problem is i want to make my client app to send authorization into the server api, so i wont ,manually copy and past token bearer in swagger. how can i fix this? what is the name of this topic? i'm new in the field. thanks.
@ndrcreates_per
@ndrcreates_per Жыл бұрын
i have done httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResponse.Token); but it wont work. please create a tutorial on this topic, its the final result of an auth and its a waste that it's not finalized.
@rezach7536
@rezach7536 Жыл бұрын
Make more videos about authentication please. Thanks
@esdegan7176
@esdegan7176 Жыл бұрын
how about refresh token?
@hosannaliving
@hosannaliving Жыл бұрын
Yes please
@leftjabrighthook
@leftjabrighthook 10 ай бұрын
Amen. There are 2993753 tutorials on .net jwt. Not one about refresh that isn’t total jank.
@tanishbansal5767
@tanishbansal5767 Жыл бұрын
I get an error while using the dotnet user-jwts create and the error I get is : dotnet : No project found at `-p|--project` path or current directory. At line:1 char:1 + dotnet user-jwts create + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (No project foun...rent directory.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError Can you please tell me the solution for this ?
@PunisherSamo
@PunisherSamo Жыл бұрын
It might be that you are not with Package Manager Console in right folder ? Try to navigate into folder where you have another folders of youre API -> like bin, Controllers, Migrations, Models, Properties and so on. Navigate there through Package Manager Console (cd "path") and check content of folder by typing command dir to be sure that you are really there. It might be because you are also trying command on already running API. Another special cases of this error I found on stack overflow go ahead and check it as well.
@akbaralimajeed
@akbaralimajeed Жыл бұрын
Hi, make sure you run above command inside the project folder not on the root folder (solution level), it requires to be in the same project file folder; hope this helps ):
@SANGCAOHOAI
@SANGCAOHOAI Жыл бұрын
@@PunisherSamoIt's so wonderful for me, witt lots of thanks, hope you earn lots of money tomorow
@dindjarin332
@dindjarin332 Жыл бұрын
Hi teacher can you cover OpenIddict library in detail?
@godizord
@godizord Жыл бұрын
Hey, great video, sadly my generated token still generates 401 error, any ideas?
@LovePeaceBeer
@LovePeaceBeer Жыл бұрын
How do you expect people to give you ideas without looking at your code? We can't use our Jedi powers unfortunately.
@sutinpoonking4104
@sutinpoonking4104 Жыл бұрын
try add audience , fix issue for me. Example: - in method CreateToken : var token = new JwtSecurityToken( issuer: _config["JWT:ValidAudience"], audience: _config["JWT:ValidAudience"], claims: claims, expires: DateTime.Now.AddDays(1), signingCredentials: creds ); - in Program.cs: builder.Services.AddAuthentication().AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, ValidateAudience = true, ValidateIssuer = true, ValidAudience = builder.Configuration["JWT:ValidIssuer"], ValidIssuer = builder.Configuration["JWT:ValidIssuer"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration.GetSection("Appsettings:Token").Value!)), }; });
@nickgendron9187
@nickgendron9187 Жыл бұрын
@@sutinpoonking4104 fixed for me, thanks!
@vishalsinghal6719
@vishalsinghal6719 Жыл бұрын
how to create token based on new login?
@vishalsinghal6719
@vishalsinghal6719 Жыл бұрын
trying to ask, how i can create token that u made using CLI
@alisayed7210
@alisayed7210 Жыл бұрын
stop sayin jesus !!!
What Is JWT and Why Should You Use JWT
14:53
Web Dev Simplified
Рет қаралды 1,2 МЛН
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
UFC 287 : Перейра VS Адесанья 2
6:02
Setanta Sports UFC
Рет қаралды 486 М.
Непосредственно Каха: сумка
0:53
К-Media
Рет қаралды 12 МЛН
Serilog 🚀 Logging in .NET 7 Made Simple & Fun
16:23
Patrick God
Рет қаралды 49 М.
Forget Controllers and Minimal APIs in .NET!
14:07
Nick Chapsas
Рет қаралды 81 М.
Implementing JWT Authentication in ASP.NET Core
23:51
Nick Chapsas
Рет қаралды 49 М.
Session Vs JWT: The Differences You May Not Know!
7:00
ByteByteGo
Рет қаралды 325 М.
ASP.NET Core JWT Authentication and role-based authorization
39:17
Angular v19 Developer Event
22:54
Angular
Рет қаралды 77 М.
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН