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

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 พ.ย. 2024

ความคิดเห็น • 91

  • @sureshthaduri6275
    @sureshthaduri6275 8 หลายเดือนก่อน +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?

  • @vandanasingh229
    @vandanasingh229 3 หลายเดือนก่อน +1

    Simple & easy way Thank you Manoj

    • @ManojDeshwal
      @ManojDeshwal  3 หลายเดือนก่อน

      Most welcome 😊

  • @DeepakSingh-hf4dx
    @DeepakSingh-hf4dx 6 หลายเดือนก่อน +1

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

  • @Saurabh.K14
    @Saurabh.K14 4 หลายเดือนก่อน +1

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

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

  • @srinivasanjayamohan8177
    @srinivasanjayamohan8177 8 หลายเดือนก่อน +1

    very clear explanation Thanks a lot Manoj!!

  • @harshitcoder7
    @harshitcoder7 2 หลายเดือนก่อน +2

    HelpFull Vedio Thank you sir

  • @camscott3013
    @camscott3013 8 หลายเดือนก่อน +1

    Simple video and explanation. Thanks.

  • @anjithhanumandla2764
    @anjithhanumandla2764 6 หลายเดือนก่อน +1

    very nice video, and detailed explanation.. superb

  • @vinothkumardhavamanoharan
    @vinothkumardhavamanoharan 4 หลายเดือนก่อน +1

    Very well explained. Thank you.

  • @manognyadasika6918
    @manognyadasika6918 8 หลายเดือนก่อน +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

  • @AlgoXperience
    @AlgoXperience 5 หลายเดือนก่อน +2

    Thank You from Tamilnadu

  • @thebrook2024
    @thebrook2024 11 หลายเดือนก่อน +2

    very well explained. Thank you Sir.

  • @shabiyabanu7990
    @shabiyabanu7990 หลายเดือนก่อน +1

    Very helpful

  • @JazilNauman
    @JazilNauman 6 หลายเดือนก่อน +1

    Very Simple and Easy.

    • @ManojDeshwal
      @ManojDeshwal  6 หลายเดือนก่อน

      Thank you 😊

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

  • @playerviii
    @playerviii 6 หลายเดือนก่อน +1

    Very clear 👏🏽🇿🇦 Thanks

    • @ManojDeshwal
      @ManojDeshwal  6 หลายเดือนก่อน

      You’re welcome 😊

  • @rasikasamith
    @rasikasamith 6 หลายเดือนก่อน +1

    Excellent video. Thanks a lot.

    • @ManojDeshwal
      @ManojDeshwal  6 หลายเดือนก่อน

      You are welcome!

  • @Gauravkumar-jm4ve
    @Gauravkumar-jm4ve 10 หลายเดือนก่อน +1

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

  • @premkumarmanjhi6806
    @premkumarmanjhi6806 11 หลายเดือนก่อน +1

    Very useful 🙏🙏

  • @muhammadsalman6768
    @muhammadsalman6768 6 หลายเดือนก่อน +1

    v good manooj

  • @mohammedmubashshirkhazi5611
    @mohammedmubashshirkhazi5611 8 หลายเดือนก่อน +2

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

    • @theos9202
      @theos9202 8 หลายเดือนก่อน

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

  • @nagarajperumal1681
    @nagarajperumal1681 7 หลายเดือนก่อน +1

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

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

  • @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 11 หลายเดือนก่อน +1

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

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

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

  • @JackPa-m2s
    @JackPa-m2s ปีที่แล้ว +1

    Thank you, you are the best ❤❤

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

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

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

  • @shabiyabanu7990
    @shabiyabanu7990 หลายเดือนก่อน +1

    Am getting 401 error after execute the loginuser

  • @parth7450
    @parth7450 ปีที่แล้ว +1

    Very useful

  • @junaidengineerings
    @junaidengineerings 8 หลายเดือนก่อน +1

    great

  • @PrasanthThennarasu
    @PrasanthThennarasu 4 หลายเดือนก่อน +1

    Thank you

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

  • @aanandkumar8824
    @aanandkumar8824 ปีที่แล้ว +1

    if i change my username or password then how login

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

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

  • @rishi_always_kushi
    @rishi_always_kushi ปีที่แล้ว +2

  • @ilkinhamid1072
    @ilkinhamid1072 11 หลายเดือนก่อน +1

    thanks

  • @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 10 หลายเดือนก่อน

      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.

    • @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 10 หลายเดือนก่อน

      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 10 หลายเดือนก่อน

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

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

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

  • @tembelninja3696
    @tembelninja3696 6 หลายเดือนก่อน +1

    why did you uncheck https

    • @Silent_Spark_
      @Silent_Spark_ 5 หลายเดือนก่อน

      For not getting http error

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

  • @KundanKumar-lr2vh
    @KundanKumar-lr2vh 6 หลายเดือนก่อน +1

    resolved

  • @Nisha_Sharma_862
    @Nisha_Sharma_862 3 หลายเดือนก่อน +1

    I need your help

    • @ManojDeshwal
      @ManojDeshwal  3 หลายเดือนก่อน +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 ปีที่แล้ว +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 👍

  • @KundanKumar-lr2vh
    @KundanKumar-lr2vh 6 หลายเดือนก่อน +1

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

  • @amiruddinsamalayawala7179
    @amiruddinsamalayawala7179 11 หลายเดือนก่อน +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 10 หลายเดือนก่อน

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

  • @imrankhan-k1o1y
    @imrankhan-k1o1y 9 หลายเดือนก่อน +1

    Thanks manoj

  • @jaidakhatoon1054
    @jaidakhatoon1054 ปีที่แล้ว +1

    How to add sql database in this

  • @gopslogsss
    @gopslogsss 8 หลายเดือนก่อน +1

    Thanks