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

Поділитися
Вставка

КОМЕНТАРІ • 92

  • @sureshthaduri6275
    @sureshthaduri6275 7 місяців тому +3

    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?

  • @harshitcoder7
    @harshitcoder7 26 днів тому +2

    HelpFull Vedio Thank you sir

  • @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

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

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

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

    Simple & easy way Thank you Manoj

  • @shabiyabanu7990
    @shabiyabanu7990 4 дні тому +1

    Very helpful

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

    very clear explanation Thanks a lot Manoj!!

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

    Very well explained. Thank you.

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

    Simple video and explanation. Thanks.

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

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

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

    very nice video, and detailed explanation.. superb

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

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

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

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

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

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

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

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

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

    Thank You from Tamilnadu

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

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

  • @thebrook2024
    @thebrook2024 9 місяців тому +2

    very well explained. Thank you Sir.

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

    Very Simple and Easy.

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

    Excellent video. Thanks a lot.

  • @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 👍

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

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

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

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

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

    Very clear 👏🏽🇿🇦 Thanks

  • @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 👍

  • @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

  • @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 👍

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

    Very useful 🙏🙏

  • @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 👍

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

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

  • @Gauravkumar-jm4ve
    @Gauravkumar-jm4ve 9 місяців тому +1

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

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

    Thank you

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

    v good manooj

  • @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 ❤❤

  • @AamJankariByYadav
    @AamJankariByYadav Рік тому +3

    Sir please make this video with entity framework .

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

      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 👍

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

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

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

      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 👍

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

    if i change my username or password then how login

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

    How to add sql database in this

  • @shabiyabanu7990
    @shabiyabanu7990 4 дні тому

    Am getting 401 error after execute the loginuser

  • @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 👍

  • @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 👍

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

    Thanks

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

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

    great

  • @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 9 місяців тому

      it will come by default !!

  • @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.

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

      tokens are used for authentication.. you should use authorization also for what you are saying

    • @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 9 місяців тому

      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 9 місяців тому

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

  • @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 👍

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

    Very useful

  • @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 👍

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

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

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

    why did you uncheck https

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

    I need your help

    • @ManojDeshwal
      @ManojDeshwal  Місяць тому +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.

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

    resolved

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

    Bhai mujhe aapse paid class Leni hai

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

      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 10 місяців тому +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 9 місяців тому

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

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

    Thanks manoj

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

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

    thanks