Secure your API Gateway with Amazon Cognito User Pools | Step by Step AWS Tutorial

Поделиться
HTML-код
  • Опубликовано: 4 янв 2025

Комментарии • 262

  • @davyboy951
    @davyboy951 2 года назад +39

    love that you don’t scrub the mistakes out of your videos. thats how real life goes, and i feel it’s important for those new to the industry to see their seniors working through mistakes. great video.

    • @BeABetterDev
      @BeABetterDev  2 года назад +13

      Mistakes happen in real life! Its important to see the whole process :D

  • @mogomotsiseiphemo1681
    @mogomotsiseiphemo1681 Год назад +18

    Great video!
    At this point 23:45, to avoid having to manually change from "code" to "token" in the redirect, you just have to select "Implicit grant" only when setting the OAuth 2.0 Auth Flow at 7:20!

  • @Ryuugaminechan
    @Ryuugaminechan 3 года назад +4

    Was stuck with this for a couple of hours now. Didn't realize that you need to deploy the API after making changes. This video really helped me. Thanks!

    • @BeABetterDev
      @BeABetterDev  3 года назад +1

      You're very welcome!

    • @duy-np3te
      @duy-np3te Месяц назад

      luckily i looked at the comment so i solve my problem in minutes. Thanks

  • @Umerfarooqai
    @Umerfarooqai 3 года назад +1

    Who were those with 5 downvotes?
    Perhaps this was one of the best and easiest tutorials to understand the concepts.

  • @bboyBoomgaarden
    @bboyBoomgaarden 3 года назад +3

    THANK YOU!!! I spent my entire day trying to figure out why I wasn't getting the id_token returned and it was because the URL i was using didn't have openid added to the URL!!!! I read every doc and stack overflow article I could find, thank you for making this video!! You got yourself another subscriber :D

    • @BeABetterDev
      @BeABetterDev  3 года назад +1

      Hi Jake,
      Super glad I was able to help you out. Thanks so much for the kind words and welcome to the channel!
      Daniel

  • @Darknightzs
    @Darknightzs 2 года назад

    ¡Gracias!

    • @Darknightzs
      @Darknightzs 2 года назад

      Thanks a lot men, great video. If you know somehting about using cognito trigers to save users statistics with lambdas, you will be mi hero haha

  • @DarknessTruth24
    @DarknessTruth24 3 года назад +4

    This was a brilliant tutorial. I have watched many videos from various people on youtube, udemy and you name it, I have been on the sites. Yet you talked in such a, lets get this done and ill show you manner instead of lots of talking but spoke about a process when needed was just great. I learned alot from this, thank you. I subbed and liked this video.

    • @BeABetterDev
      @BeABetterDev  3 года назад +2

      Thank you so much for your kind words Daryl. I always try to present my content in a relatable way that synthesizes the complexity of a topic into an easy to understand presentation. I'm glad you found this useful - and thank you for the kind words!
      Daniel

  • @rohitghalistudies
    @rohitghalistudies 3 года назад +3

    Mind blown... Was looking for exactly this. Fantastic.

  • @fatihersoy7559
    @fatihersoy7559 2 года назад

    This video made me subscribe to your channel immediately. It's impressing how easy to understand from you, especially after spending hours on understanding nothing about the topic.

  • @thetrilbies1
    @thetrilbies1 7 месяцев назад +3

    Any chance of a refresher video using the latest version of cognito and API gateway?

  • @rajapoudel5037
    @rajapoudel5037 2 года назад +1

    Thanks for making the tutorial video. This video helps me a lot.

  • @eugenevedensky6071
    @eugenevedensky6071 3 года назад +14

    This video along with your RDS lambda integration video is pretty much all you need to get a robust web app going super quickly. Great content.
    EDIT: In case you ever read this, do you have any insight how you might apply RBAC with this strategy?

  • @jeromeeusebius
    @jeromeeusebius 3 года назад +1

    BeABetterDev: Thanks for putting this video together. I followed the API Gateway Lambda one and this version with Cognito. The option is Cognito is much richer and I will be exploring it with my app. It is good that the video is also an actual workthrough with details and it was easy and nice to follow and I was able to replicate the results.

  • @kreeve6144
    @kreeve6144 Год назад +1

    Love this video! The only thing I've found different in my scenario is that passing the Authorization header won't work with the access token. It only works with the id token for some reason

  • @scottjennings2165
    @scottjennings2165 2 года назад +1

    this just saved a ton of time. Forgot to deploy API and was using the test URL or some shit. Thanks bro

    • @BeABetterDev
      @BeABetterDev  2 года назад +1

      You're very welcome Scott! I've been bitten by that problem too many times.

  • @cachuelasaimonrobertl.455
    @cachuelasaimonrobertl.455 3 года назад +1

    You're an absolute mad lad! saved me hours of reading docs lol

  • @sebastiencrepel5032
    @sebastiencrepel5032 2 года назад +1

    Hello. Thank you so much. This step by step video is a gold mine !

  • @kishanlal676
    @kishanlal676 2 года назад +7

    23:49 I guess you don't have to do that manually if you allow only the 'Implicit grant' when you check the 'Allowed OAuth Flows' section at 7:25 which would set the response_type to token automatically. But, this is not suggested unless you're using a Single Page App without any backend

  • @ChardsonX
    @ChardsonX 3 года назад +3

    I want to thank you! This lesson was really helpful and straightforward. Congratulations!

    • @BeABetterDev
      @BeABetterDev  3 года назад

      You're very welcome Ricardo! Thanks for the kind words!

  • @arpankhetani7818
    @arpankhetani7818 Год назад

    Thank you for the well explaination of the Cognito and the demo.. It worked smoothly for me following the steps you mentioned..

  • @INMYMIND1221
    @INMYMIND1221 Год назад

    This is amazing, this helps me a lot in building side projects user authentication!!

  • @nayanc4353
    @nayanc4353 3 года назад +4

    Thanks for this, just what I needed. Next, can you show how to provide access to user to a subset of lambda functions or APIs, instead of access to all?

  • @deecee2204
    @deecee2204 3 года назад +2

    love this video, more on serverless architecture pls

  • @cass4649
    @cass4649 3 года назад +1

    Thank you for your videos. They are amazing, the notification is enabled in order to receive news content 😀

  • @chandeepsingh4161
    @chandeepsingh4161 3 года назад

    Bhai aapne balle balle karwa di!

  • @kmilo4307
    @kmilo4307 8 месяцев назад +1

    Thanks. I was waiting to see at the end the web page with the fields requesting for username and pw

  • @ppgg997
    @ppgg997 2 года назад +4

    Great explanations!! One question, on authorizer test , you used Token id but calling the api path from Postman you put in header the access token instead. Whats the difference and why each one needed in the corresponding scenario?

  • @ihorkonovalenko9389
    @ihorkonovalenko9389 2 года назад +1

    Thanks for great practical explanation! Very useful video.

  • @ineedabetterhandle
    @ineedabetterhandle 3 года назад +1

    Exactly what I was looking for. Thanks! You just got yourself another sub

    • @BeABetterDev
      @BeABetterDev  3 года назад +1

      Thanks Tonislav and welcome to the channel!

  • @pms123ms
    @pms123ms 2 года назад

    amazing video, just right speed and right contents for api security with AWS

  • @ComupXChinx
    @ComupXChinx 2 года назад +1

    Could your make a Identity Pool video of how to set different users have different API permissions

  • @ryanl8119
    @ryanl8119 Год назад

    Dude, this video is gold. Thank you 🙏

  • @niceOneSonnyAgain
    @niceOneSonnyAgain 3 года назад +5

    I had clicked “like” even before watching this guy’s video.

    • @BeABetterDev
      @BeABetterDev  3 года назад

      Thank you so much for your support!

    • @jodwbe
      @jodwbe Год назад

      I thumbs up your comment before liking and watching the video. This comments is all I needed to know 😂

  • @isharanka6020
    @isharanka6020 2 года назад +1

    thank youuuu for this tutorial. Helped me a lot!!

  • @jonathanfalcone3437
    @jonathanfalcone3437 3 года назад +10

    This video is amazing! Very generous of you to take time and publish this for public viewing. Just out of curiosity is it possible for a user to login via the HostedUI and then have access to api gateway via the browser? If you don't have tech savy customers they likely don't want to access the API via Postman but would prefer to just login and have access, any chance if you know this is possible ? Thanks so much again :)

    • @BeABetterDev
      @BeABetterDev  3 года назад +1

      Hi Jonathan,
      Hm, I don't think this is possible using any out of the box tools unfortunately. Sorry to share the bad news. I think it wouldn't be too much work to create a simple React app with a couple input boxes / text areas to call the corresponding UI once logged in.
      Thanks so much for the kind words!
      Daniel

    • @SilviasBrainery
      @SilviasBrainery Год назад

      @@BeABetterDev i guess this answers my question.....

  • @arkadiyshuvaev
    @arkadiyshuvaev 3 года назад +1

    Great work! I have learnt a lot from your video. Thank you and all the best :)

  • @markthien
    @markthien 2 года назад

    Very nice tutorial bro!

  • @craigmacritchie3087
    @craigmacritchie3087 3 года назад +1

    This was great! awesome job Daniel!

    • @BeABetterDev
      @BeABetterDev  3 года назад

      Thanks Craig! Glad you enjoyed :)

  • @HussainMohammedAshruf
    @HussainMohammedAshruf 2 года назад +1

    Daniel excellent. Covered much in the 30 minutes. I am a bit confused about JWT Id Token vs Access Token which one to use in the Authorization Header. While testing the Cognito UserPool you have used JWT Token vs While testing the API used Access Token.

  • @JoshPeak
    @JoshPeak 3 года назад +1

    Currently running into issues trying to adapt this to the "HTTP API" on API Gateway to use Cognito User Pools as an authorizer but stumbling on the step about JWT as a source. I'll fumble my way through it and I wanted to say that I am grateful your content getting me this far. Authorizing the new HTTP API Gateway could be another idea for content if that's something to add to your list of content ideas. Thanks for the high quality content though ^_^

    • @BeABetterDev
      @BeABetterDev  3 года назад +1

      Hey josh,
      Have you tried taking a look at my video on HTTP APIs in API Gateway? I think you can possibly combine the content from this video and the one below.
      ruclips.net/video/M91vXdjve7A/видео.html
      Hope this helps.
      Daniel

    • @JoshPeak
      @JoshPeak 3 года назад +1

      @@BeABetterDev thanks for the reply. I managed to fumble my way through it with this video ruclips.net/video/o7OHogUcRmI/видео.html
      The one you just linked me, filled in some gaps for me about logging and cloud watch. 👏
      Thanks again for all of your content. I’ve smashed the like 👍 button on all the videos that I have watched (to feed the algorithm).

    • @BeABetterDev
      @BeABetterDev  3 года назад

      Thanks so much Josh! I'm glad you were able to work through it and appreciate the support! Thanks again and stay safe :)

  • @longdo6858
    @longdo6858 3 года назад +1

    thanks u! I get stuck until get your video!

  • @dekcode2824
    @dekcode2824 3 года назад +1

    This is gold. Thanks man

  • @fahimfahad7026
    @fahimfahad7026 3 года назад +1

    Excellent video

  • @fabian-manzano
    @fabian-manzano 11 месяцев назад +1

    So nice video, I love it, can I ask to get the token, you ammend the URL from code to token, however if my user wants to get this value programmatically, how they would do that?

  • @SyntekkTeam
    @SyntekkTeam 3 года назад +7

    Hi, thanks for making this, it was super helpful, and well explained
    I was able to get everything from the tutorial working, but once the lambda is called, I'd like to access the cognito user id so that I can update user specific information. I was hoping that apigateway would pass along the user id and/or token over to lambda, but it doesn't. How would you handle this?
    EDIT: Figured it out, I had to check the "Use Lambda Proxy Integration" at 17:46. Then all the header/query info become available through the lambda event variable

    • @BeABetterDev
      @BeABetterDev  3 года назад +1

      Hi Arend, just got to this comment now - I see you got your question answered, glad to see. Thanks so much for the kind words and glad I could help!

    • @firefighter8083
      @firefighter8083 2 года назад

      Helped me a lot. Thank you!

  • @swaminathbera_a1
    @swaminathbera_a1 Год назад

    Awesome Man, Thanks for the hard way tip!! 😇😇

  • @chrisnuttle4302
    @chrisnuttle4302 2 года назад

    Actually practical thanks a lot. This has helped me a lot.

  • @rsouza01
    @rsouza01 2 года назад +1

    Freaking amazing video!! Kudos for u! Learned a lot!

  • @jasusig8946
    @jasusig8946 3 года назад +1

    You are the best bro, thanks.

  • @FundaDuval-eb8qj
    @FundaDuval-eb8qj 8 месяцев назад +1

    Hi I love the pace & no fluff! I have 2 questions: 1) Can you use user pool authorizers with federated ID integration (like with AzureAD)? User will be using SSO. and 2) does this remove the need/use-case for Lambda@Edge?

  • @inacomic
    @inacomic 2 года назад +1

    Top man! Thank you for creating this - and including the fail! lol

    • @BeABetterDev
      @BeABetterDev  2 года назад +1

      You're very welcome! The fails just adds to the realism :P
      Cheers

    • @inacomic
      @inacomic 2 года назад

      @@BeABetterDev Hi 👋 Do you have a video walking through adding a cognito user to a dynamodb?

  • @thetedsingh
    @thetedsingh 3 года назад +1

    This was awesome, but could you show how I could get from curl/Postman how to get the access token?

  • @sbnlalpnr
    @sbnlalpnr 2 года назад

    Nice explanation. Thank you

  • @hbladeh
    @hbladeh Год назад

    If I understand correctly what you did is basically by writing token into the URL you switched from "Authorization code" grant to "Implicit" grant type. If you're using a URL that's outside of AWS and travels through the web use code instead and use the Token endpoint of the identity provider (in this case Cognito), to get a token in the Body, and post it as a header in the HTTP Request, not as the part of the URL itself.

  • @Ronaldograxa
    @Ronaldograxa 10 месяцев назад

    thanks for that.. Hard to find someone going through custom domain in cognito..

  • @st3114rr
    @st3114rr 3 года назад +1

    This was so helpful--thanks a ton!

  • @sohanbafna2282
    @sohanbafna2282 Месяц назад

    Love to watch this- good explanation . Only one thing i think you should highlight - "Using Implicit flow is not recommended approach as it exposes access_token in browser url"

  • @surly_mel
    @surly_mel 2 года назад

    Thanks for the great video! I'd gotten past the initial login step just fine but had no idea what to do with the tokens passed back. Got a bit of template work to do linking the Lambdas/Gateway/Cognito but it should be easy peasy thanks to your demo.

  • @tanujgupta-b2x
    @tanujgupta-b2x Год назад +1

    An error was encountered with the requested page.
    i am getting this error when i change respose type to token
    what should i do

  • @derangeer
    @derangeer 3 года назад +1

    Cool! awesome demo and great explanation.

  • @TheDhanuroutu
    @TheDhanuroutu 3 года назад +5

    How can we give access to a specific API to a user using the cognito authorizer?

  • @joaovitor12full
    @joaovitor12full Год назад

    thank you very much, that's just what i needed

  • @alexandromaldonado2182
    @alexandromaldonado2182 3 года назад +1

    Awesome explanation

  • @tasleemhussein5228
    @tasleemhussein5228 3 года назад +1

    Awesome video, thanks bud!

  • @vk2875
    @vk2875 3 года назад +1

    Thanks, this is just an excellent tutorial !!!

  • @berkslv
    @berkslv 3 года назад +1

    Thanks for great explanation !

  • @shaunmccullagh5116
    @shaunmccullagh5116 Год назад

    Superb video, great stuff many thanks for posting

  • @mohammadrezabagheri8336
    @mohammadrezabagheri8336 3 года назад +1

    Thanks, awesome job!

  • @GauravRoy1972
    @GauravRoy1972 2 года назад +1

    The last step with postman isn't working. I have tried all variations to the process/ settings. Is there a bug with Amazon. Followed all these instructions but the access token based request is always giving an "unauthorised message" response.

  • @branquitodemunze
    @branquitodemunze 2 года назад +1

    Thanks a lot! Great explanation.

  • @radu2329
    @radu2329 3 года назад +1

    Amazing job,man. THANK YOU SO MUCH

  • @ajaygulani3086
    @ajaygulani3086 2 года назад +2

    Great video! Just a question - how come when you point to the URL for the API it does not redirect to the login page? or would you need to create that in your client side code in something like an "IF" statement?

  • @etseale
    @etseale 3 года назад +1

    Nicely explained! Even I understand it. :) Thank You!

    • @BeABetterDev
      @BeABetterDev  3 года назад +1

      Thanks etseale! Glad you enjoyed :)

  • @ToreyLittlefield
    @ToreyLittlefield 3 года назад +1

    Masterclass. Thank you 🙏🚀

  • @caleyCodeLab
    @caleyCodeLab Год назад

    you're a king

  • @lucasterable
    @lucasterable 2 года назад +1

    Can a client app login into Cognito programmatically to get the token? That is, in an IoT context where no browser is involved involved.

  • @imagesxpertmedia5105
    @imagesxpertmedia5105 3 года назад

    Great job. Please do you offer mentorship program. I need to lean more on AWS infrastructure projects

  • @theethicalh3707
    @theethicalh3707 3 года назад +1

    thank you very much bro i want to like that video 100000000 time

  • @blackDrk
    @blackDrk 3 года назад

    Thanks bro you saved me!!!!!!!! great video

  • @PavanSibal
    @PavanSibal 3 года назад +1

    Thanks for a great tutorial. How can I use Amazon Cognito in multi-region scenario?

    • @BeABetterDev
      @BeABetterDev  3 года назад +1

      Hi Pavan, it looks like AWS now supports this natively. Check out the announcement here: aws.amazon.com/about-aws/whats-new/2020/04/introducing-multi-region-user-pools/

  • @damoga55
    @damoga55 3 года назад +1

    Thank you very much, this video helped me a lot.

  • @free_intertaining
    @free_intertaining 2 года назад +1

    how u do it programmatically????

  • @karthiksakthivel7108
    @karthiksakthivel7108 2 года назад

    Simple and super video...

  • @saveplatypus
    @saveplatypus 3 года назад +1

    Thank you sir. Very helpful. You should ask for a raise. :)

  • @The.Traveling.Nerddd
    @The.Traveling.Nerddd Год назад

    Nicely explained

  • @rakandhiyaaa92
    @rakandhiyaaa92 3 года назад +2

    thank you so much for the tutorial, I have a question: suppose I am using amazon cognito for authentication, and I have a table in AWS RDS that requires me to have a user id for foreign key purposes, is that doable with amazon cognito? if it is doable, what do I need to do?

    •  3 года назад

      I have the same concern with you. I also want to import user_id and their full name in the RDS to manage users. Please clarify this, Daniel

    • @braydenwilson4484
      @braydenwilson4484 3 года назад

      I am new to AWS new stack but spend a lot of time with basic AWS service, GCP, SAP Cloud and Other Cloud Vendor.
      It seems to be a vendor locking thing, after little research, it seems you can only use APIs to get things done.
      It stores 25 fields max for a user and everything is money this is the part they will grab by neck you so you can not jump board if your application needs to be switch outside the AWS.

  • @eiderantonioarangoamaya8475
    @eiderantonioarangoamaya8475 3 года назад

    Thanks bro, nice video. Highly appreciate it.

  • @shubhampahurkar298
    @shubhampahurkar298 3 года назад +1

    very helpful. Thanks a lot

  • @saeeduchiha5537
    @saeeduchiha5537 2 года назад +1

    Up until 23:38 everything was fine. But once you change the response type from "code" to "token" it gives me an "unauthorized_client" error.

    • @TheSreemanth
      @TheSreemanth 2 года назад

      Check all the options OAuth 2.0 at 7:58, I had similar issue and fixed after I selected all the demoed option

    • @MasoudGhaffarinia
      @MasoudGhaffarinia Год назад

      @@TheSreemanth This is not a fix though. AWS does recommend using PKCE code instead of directly having access token in url. This video does not cover.

  • @michaelakin766
    @michaelakin766 2 года назад

    Thanks for this video. Question. Why does AWS not require "Bearer" in the Authorization header like seems to be standard everywhere else?

  • @amarnatha1614
    @amarnatha1614 10 месяцев назад

    So nice & useful...

  • @galzafar2943
    @galzafar2943 2 года назад

    I liked the tutorial, very clear and precise. how do you accomplish machine to machine authentication ie. using a client id and secret (from my shallow understanding). as I understand I would either send the client id and secret to the endpoint, and the api gateway will take care of it, which is a better option in my opinion. the other other would be to request an access token (using the id and secret) and then using that to authenticate.
    what is the "right" way?

  • @vasudeva1408
    @vasudeva1408 Год назад

    Good demo

  • @田英俊
    @田英俊 3 года назад +1

    Thank you very much

  • @AhumadaMauricio
    @AhumadaMauricio 2 года назад +1

    Great video. I think there's a little change in the way the authorization token is validated in the api gateway, in order to send a request using postman make sure you send the token using the Authorization tab and selecting "Bearer " on the dropdownlist. Do not include the token on the URL as this will not be correctly authorized by api gateway.

  • @5190csyt
    @5190csyt 3 года назад +1

    How can we log in by cognito and get the response from lambda directly? instead of copy and paste access token....

  • @Puttosenkanava
    @Puttosenkanava 3 года назад +1

    Is there a way to make the cognito-authorizer only allow certain usergroups from Cognito to invoke the lambda or do I need to make own lambda authorizer?

  • @simonwaffleman
    @simonwaffleman 2 года назад +1

    Would love this in Terraform instead of the UI so that can examine the details in GitHub or something.

  • @thamizhi6819
    @thamizhi6819 3 года назад

    i am trying to use this method with amplify base vue app. got some pointers going to explore

  • @freeworldtour
    @freeworldtour 3 года назад +1

    OMG...yes i need this useful video...