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

Поділитися
Вставка
  • Опубліковано 27 січ 2025

КОМЕНТАРІ • 98

  • @sureshthaduri6275
    @sureshthaduri6275 10 місяців тому +4

    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?

  • @vasujain5469
    @vasujain5469 7 днів тому +1

    Thanku so much sir amazing tutorial

    • @ManojDeshwal
      @ManojDeshwal  2 дні тому

      Hello,
      Welcome to my channel, and thank you for your comment!
      For any inquiries or technical assistance, feel free to connect with me on WhatsApp at +91 9625701241 or send me a message on Instagram at @manojdeshwal.dev.
      Looking forward to assisting you!

  • @DeepakSingh-hf4dx
    @DeepakSingh-hf4dx 8 місяців тому +1

    Finally the best video I got about JWT. Their a lot of confusion before . Thank you a lot

  • @srinivasanjayamohan8177
    @srinivasanjayamohan8177 10 місяців тому +1

    very clear explanation Thanks a lot Manoj!!

  • @harshitcoder7
    @harshitcoder7 4 місяці тому +2

    HelpFull Vedio Thank you sir

  • @vandanasingh229
    @vandanasingh229 5 місяців тому +1

    Simple & easy way Thank you Manoj

  • @Saurabh.K14
    @Saurabh.K14 6 місяців тому +1

    Great explanation ❤ Finally I learned how to use auth middleware with JWT Token ✌️👏🏻

  • @camscott3013
    @camscott3013 11 місяців тому +1

    Simple video and explanation. Thanks.

  • @anjithhanumandla2764
    @anjithhanumandla2764 8 місяців тому +1

    very nice video, and detailed explanation.. superb

  • @vinothkumardhavamanoharan
    @vinothkumardhavamanoharan 7 місяців тому +1

    Very well explained. Thank you.

  • @manognyadasika6918
    @manognyadasika6918 11 місяців тому +1

    all thanksss tooo youuu bhaiayyaa... cannt sayyy it helpeeddd a lotttt .... u r the besttttt

  • @thamotharan-xl8ce
    @thamotharan-xl8ce Рік тому +2

    Thank you Bro !!! simple and easy way to understand

  • @thebrook2024
    @thebrook2024 Рік тому +2

    very well explained. Thank you Sir.

  • @AlgoXperience
    @AlgoXperience 7 місяців тому +2

    Thank You from Tamilnadu

  • @JazilNauman
    @JazilNauman 8 місяців тому +1

    Very Simple and Easy.

  • @playerviii
    @playerviii 9 місяців тому +1

    Very clear 👏🏽🇿🇦 Thanks

  • @Venkatesh_Averi
    @Venkatesh_Averi Рік тому +8

    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

    • @ANISHKUMAR-fq3hw
      @ANISHKUMAR-fq3hw 20 днів тому

      same question from my side in real time jwt token we got from service provider so please suggest ...

  • @shabiyabanu7990
    @shabiyabanu7990 3 місяці тому +1

    Very helpful

  • @hz73219
    @hz73219 Рік тому +2

    Thank you !!! simple and easy to understand

    • @ManojDeshwal
      @ManojDeshwal  Рік тому

      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 👍

  • @nagarajperumal1681
    @nagarajperumal1681 9 місяців тому +1

    Why do we need to give same value for issuer and audience?

  • @premkumarmanjhi6806
    @premkumarmanjhi6806 Рік тому +1

    Very useful 🙏🙏

  • @rasikasamith
    @rasikasamith 8 місяців тому +1

    Excellent video. Thanks a lot.

  • @muhammadsalman6768
    @muhammadsalman6768 8 місяців тому +1

    v good manooj

  • @kartikmondal4933
    @kartikmondal4933 Рік тому +2

    Thank you so much, sir. This video helps me a lot.

    • @ManojDeshwal
      @ManojDeshwal  Рік тому

      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 👍

  • @ami.12345
    @ami.12345 Місяць тому +1

    Thank you ❤

    • @ManojDeshwal
      @ManojDeshwal  Місяць тому

      Hi, welcome to my channel and thanks for the comment.
      For any query or technical help, please connect on WhatsApp number +91 9625701241 or message me on my Instagram @manojdeshwal.dev.

  • @mohammedmubashshirkhazi5611
    @mohammedmubashshirkhazi5611 10 місяців тому +2

    Why did you use GenerateToken(Users users) if users is not used in this method?

    • @theos9202
      @theos9202 10 місяців тому

      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);
      }

  • @Guru83591
    @Guru83591 Рік тому +1

    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 👍

  • @chandankarmakar6651
    @chandankarmakar6651 Рік тому +1

    Thank you, this tutorial helped me lot!

    • @ManojDeshwal
      @ManojDeshwal  Рік тому

      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 👍

  • @JackPa-m2s
    @JackPa-m2s Рік тому +1

    Thank you, you are the best ❤❤

  • @ratnakarsethi8403
    @ratnakarsethi8403 Місяць тому +1

    Thank you sir

    • @ManojDeshwal
      @ManojDeshwal  Місяць тому

      Hi, welcome to my channel and thanks for the comment.
      For any query or technical help, please connect on WhatsApp number +91 9625701241 or message me on my Instagram @manojdeshwal.dev.

  • @shabiyabanu7990
    @shabiyabanu7990 3 місяці тому +1

    Am getting 401 error after execute the loginuser

  • @Gauravkumar-jm4ve
    @Gauravkumar-jm4ve Рік тому +1

    very good explanation , subscribed! thank u , and pls keep sharing more

  • @sajjadhusain8457
    @sajjadhusain8457 Рік тому +1

    thank you so much brother god bless you !!!!!!!!!!!!

  • @nangdalet5994
    @nangdalet5994 2 роки тому +2

    Can you demo follow this video using dynamic user with database and using store procedure

    • @ManojDeshwal
      @ManojDeshwal  2 роки тому

      Hi, welcome to my channel and thanks for the comment. Could you connect on Instagram @openprogrammer is my Instagram handle.
      Keep learning and supporting 👍

  • @testtest-c4z
    @testtest-c4z Рік тому +1

    What is the difference between Claim and Signature? what does each one reference?

    • @ManojDeshwal
      @ManojDeshwal  Рік тому

      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 👍

  • @HeyJunaid
    @HeyJunaid 10 місяців тому +1

    great

  • @parth7450
    @parth7450 Рік тому +1

    Very useful

  • @SomethingSpiritual
    @SomethingSpiritual Рік тому +2

    Hi Manoj, token expiration not working. I have put 1 min but after 1 min its not expiring. thanks for this video.

    • @ManojDeshwal
      @ManojDeshwal  Рік тому +1

      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

  • @debasispanda7322
    @debasispanda7322 Рік тому +1

    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 👍

  • @rishialwayskushi
    @rishialwayskushi Рік тому +2

  • @Poojathaduri
    @Poojathaduri Рік тому +2

    How to do this with db connection

    • @ManojDeshwal
      @ManojDeshwal  Рік тому

      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 👍

  • @aanandkumar8824
    @aanandkumar8824 Рік тому +1

    if i change my username or password then how login

  • @PrasanthThennarasu
    @PrasanthThennarasu 6 місяців тому +1

    Thank you

  • @virendras7554
    @virendras7554 2 роки тому +1

    What happens when token gets expired? will user need to re send the credentials?

    • @ManojDeshwal
      @ManojDeshwal  2 роки тому

      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 👍

  • @KundanKumar-lr2vh
    @KundanKumar-lr2vh 8 місяців тому +1

    Hi Bro, It's failed to get load swagger in .net 8 "giving internal server error"

  • @AamJankariByYadav
    @AamJankariByYadav 2 роки тому +3

    Sir please make this video with entity framework .

    • @ManojDeshwal
      @ManojDeshwal  2 роки тому

      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 👍

  • @NuumanIsaev-x3x
    @NuumanIsaev-x3x Рік тому +1

    how we can set up swagger ?

    • @ManojDeshwal
      @ManojDeshwal  Рік тому

      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 Рік тому

      it will come by default !!

  • @tembelninja3696
    @tembelninja3696 8 місяців тому +1

    why did you uncheck https

  • @prakashm7875
    @prakashm7875 Рік тому +1

    At 9.18 how to give the website name

    • @ManojDeshwal
      @ManojDeshwal  Рік тому

      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 👍

  • @ilkinhamid1072
    @ilkinhamid1072 Рік тому +1

    thanks

  • @AdiSaxena-s4m
    @AdiSaxena-s4m Рік тому +1

    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.

    • @AdiSaxena-s4m
      @AdiSaxena-s4m Рік тому

      ?

    • @ankurkatiyar07
      @ankurkatiyar07 Рік тому

      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 Рік тому

      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 Рік тому

      @@officialamritnepal 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!!!

  • @jayantverma4639
    @jayantverma4639 Рік тому +1

    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 👍.

  • @Venkatesh_Averi
    @Venkatesh_Averi Рік тому +1

    Thankyou so much bro,if possible can you provide the github link of this bro

    • @ManojDeshwal
      @ManojDeshwal  Рік тому

      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 👍

  • @KundanKumar-lr2vh
    @KundanKumar-lr2vh 8 місяців тому +1

    resolved

  • @Nisha_Sharma_862
    @Nisha_Sharma_862 5 місяців тому +1

    I need your help

    • @ManojDeshwal
      @ManojDeshwal  5 місяців тому +1

      Hi, welcome to my channel and thanks for the comment. Please connect on WhatsApp on this number +91 9625701241 or message me on my Instagram @manojdeshwal.dev.
      Keep learning and supporting.

  • @Javedinsha
    @Javedinsha 2 роки тому +1

    Bhai mujhe aapse paid class Leni hai

    • @ManojDeshwal
      @ManojDeshwal  2 роки тому

      Hi Javed, welcome to my channel and thanks for the comment. Kindly connect on Instagram @openprogrammer is my Instagram handle.
      Keep learning and supporting 👍

  • @amiruddinsamalayawala7179
    @amiruddinsamalayawala7179 Рік тому +1

    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 Рік тому

      in that case, you can choose the package of version 6.0.0, It will work!!!

  • @imrankhan-k1o1y
    @imrankhan-k1o1y 11 місяців тому +1

    Thanks manoj

  • @jaidakhatoon1054
    @jaidakhatoon1054 Рік тому +1

    How to add sql database in this

  • @gopslogsss
    @gopslogsss 10 місяців тому +1

    Thanks