Upgrading to .NET Core: Adding JWT Authentication to Our API - A TimCo Retail Manager video

preview_player
Показать описание
Authentication in ASP.NET Core API is different than in WebAPI. In this video, we are going to implement a JWT system so that our new API will send tokens like our old system did. We will also implement Swagger and make some other system improvements.

One-off tutorials are awesome but they aren't the only thing you should be doing to learn C#. Another vital part of learning is learning how to put it all together. This interactive course is all about putting the pieces together. You can watch each video on its own or you can watch them in order and see a bigger picture. The choice is yours.

This course focuses on real-world development. As such, we are simulating that we work for TimCo Enterprise Solutions on a brand new product, the TimCo Retail Manager. Just like in the real world, we are starting out with one set of requirements but know that over time they will change.

0:00 - Intro and overview
21:47 - Setting up JWT
1:00:45 - Swagger Implementation
Рекомендации по теме
Комментарии
Автор

Hello Tim. It is me again. I have struggled to finish this lesson more then 3 days in row, JWT authentication did not work as it should. I started debugging session, and surprise it took me 3 days to make things working as you have in your lesson. I still don't know were my mistake was, but revert 2 last commits, started from scratch, and finally it works.
It was not an easy experience, but it is a part of software development.
I wish everyone do not have so long debugging session. ))
I can continue follow you and hopefully I will catch you up in phase 3.
Thank you.

dmytrohryshyn
Автор

Been waiting for JWT for almost a year! I know a lot of tutorials showing different ways of how to implement this, but I've been waiting on Tim's version since he explains why we should do it that way and how we can use it in our own projects.

matterece
Автор

No lie Tim. This authentication step nearly broke me. Fantastic video!

Also thank you, comment section. Y'all saved me a couple times lol.

copperntz
Автор

52:27 I still think you're superman <3 thanks for all the work you've put in over the years. This channel has some great content.

pigeonfigther
Автор

Great Tutorial Tim. I’m following the Timco retail course. This video helps me to understand the benefit of using dependency injection in that course.
Thanks a lot.

lebeluet
Автор

Some checkpoints below
Setting up JWT at 21:47
Setting up the Authentication in Startup.cs 49:10
Swagger Implementation at 1:00:45

amitthakur
Автор

13:50 Ohh my god! soo simple to find the users roles!
Thank you soo much, i've been looking for that for ages!

DukaSoft
Автор

Thank you so much for this Tim. Great work!!! I can't wait for the addition of refresh tokens

reagang
Автор

If somebody gets " 'AuthenticationBuilder' does not contain a definition for 'AddJwtBearer' and no accessible extension method 'AddJwtBearer' accepting a first argument of type 'AuthenticationBuilder' could be found (are you missing a using directive or an assembly reference?)", include package Microsoft.AspNetCore.Authentication.JwtBearer, but use Version 3.0.0.

borisgeorgiev
Автор

Good work. I have found several of your videos very helpful. Thank you.

nelsonrivers
Автор

This is great. JWT is explained in the best one could explain and understand. "Simply Perfect"

wau
Автор

For some reason the "var result = await from the could not quite fill the field "Access_Token" of AuthentificatedUser. Each of my attempt kept filling it with "null".
After poking aroud for a bit, found out that the "ReadAsStringAsync", on the other hand, would get me the desired token. Hmm, strange.
Poked a bit more and ... Fixed my issue.
It seems like the "_" of "Access_Token" was the source of the problem. Changed it to "Token" and everything went fine.

Made me debug for few hours and dive into the code a bit more, had a blast!

Once again, thank you very much for all this golden content, you ROCK !

quentincouissinier
Автор

Is just something in the way Tim explains things!

carlosalmeida
Автор

Thats a lot of documentation to read Thanks Tim. :)

aminebenhebba
Автор

55:04 For everyone getting this failed msg (or something similar) "Exceptions caught: '[PII is hidden]'. token: '[PII is hidden]'." try increasing the lenght of your secret encryption password. In my case it needed to be atleast 1024 bytes so i just added some random words. Error is really unclear tho... but it did fix it

markdekuijer
Автор

Excellent video. Covers all the key topics.

timw
Автор

Just a note on I tried to install the latest 5.0 version and it was rejected because it did not support .NetCoreApp 3.1. I had to specifically select the 3.1.0 package.

LarryB
Автор

Lol happy to see it's not just me 😂
Here's an idea for a video: setting up a STS using IdentityServer

gert-janvanderkamp
Автор

i like that ur making webservice secure via jwt, thats what im thinking of having for the soln im working on now.
but there are many bits like refresh token that is needed to figureout., but i guess, your post confirm that jwt can also be used not just for sso/auth, but also for auth for web-api

faridmohdismail
Автор

Hello Tim I skipped through a few videos after this one before I bothered you with this question, but it doesn't seem as though a possible bug was addressed. Logging in on the MVC page no longer works correctly after adding the JWT authentication codeblock in the StartUp file. After logging in it just loads up the home page with the options to register and login. You also can't use the controller routes since they require you to be authorized. What I find strange is if you comment out the JWT code block in StartUp and launch the API again you are already logged in as whichever user you tried to log in as when the JWT code block was active. Also just in case it matters you can log in to the WPF app just fine its only the MVC page that's giving the issue. I tried moving that particular codeblock higher on the order and I also downloaded your source code and created a user, but I still ran into the same bug. This is the first time I've dealt with Authentication and the first time I even heard of JWT, so while I've tried I have been unable to solve this.

karatekid