FastAPI + Github OAuth

Поділитися
Вставка
  • Опубліковано 19 сер 2024
  • Quick tutorial of using the Github OAuth app flow with FastAPI.

КОМЕНТАРІ • 35

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

    thx this is so cool and your instructions are clear keep up

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

    Very good tutorial, thanks!!!

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

    Thanks dude, your video help me a lot

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

      Appreciate it! Let me know if there’s other content you’d be interested in 👍

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

    awesome tutorial man

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

    great tutorial. if you could post the code in git or gist, would make it even better!

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

      @@romanmikhailov5932 thanks! That is my one regret about this video, didn’t save the code 😞😞

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

    Great video!

  • @user-ye6jj9yf8g
    @user-ye6jj9yf8g 11 місяців тому +1

    Extremely helpful! Thanks a lot!

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

    thank you ❤

  • @mathis7117
    @mathis7117 9 місяців тому

    thank you it's perfect

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

    Thank you very much, very informative
    Can you please make a video what to do when there are several oauth providers on the site how to create a database and store users?

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

      Multiple OAuth providers and a DB? Got it. I’ll try to get something out for you 👍

  • @yiouyou
    @yiouyou 4 місяці тому

    Failed to follow the example code, how the app know it should go to github-code after clicking the authorization button of github-login?

    • @EstesAdvTech
      @EstesAdvTech  4 місяці тому

      Hi - Are you referring to timestamp 4:08 where I create the OAuth app? There are 2 URLs to enter, the homepage and callback. The callback is what tells it to go the the /github-code URL in my application after authorization

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

    Hi Will. Thanks for the mazing video. I was wondering how do you go about implementing integration testing with Oauth ?

    • @EstesAdvTech
      @EstesAdvTech  8 місяців тому

      Integration testing with OAuth gets a little hairy, so it really depends on what kind of testing you'd like to do. Offhand, there's a few options available (not in any particular order, I'll add more if I think of any)
      1. Create a mock token for the OAuth provider and use a mock server to replicate the functionality
      2. Create test user(s) for use in your tests so "real" interactions can occur
      3. Create an application token through the oauth provider (like oauth-playground in Googles GCP. I've never used these but they might be promising)
      I've seen numbers 1 & 2 in practice.
      I think the question you need to answer is "Am I testing the OAuth provider as well as my code?" - If you answer no (most cases), then a mock token/server is likely a good option. If yes, creating a test user(s) might be the way to go.
      Hope this helps!
      Thanks for watching!

    • @nischalsehrawat2130
      @nischalsehrawat2130 8 місяців тому

      @@EstesAdvTech Thanks for the answer. Another question. Does Github support OIDC. Because I don't get any refresh token back nor an ID token. Any ideas ?

    • @EstesAdvTech
      @EstesAdvTech  8 місяців тому

      ​@@nischalsehrawat2130 I was able to find this: docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28
      Hope this helps!

  • @a.s8840
    @a.s8840 Рік тому

    Can you please tell me how to do same with Google

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

    what if i get a CORS error? i can't even trigger the redirect

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

      did you double both your urls in github? I didnt setup any configurations for CORS so my guess is it's specific to your environment?

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

      i’m trying with gitlab and oauth2 but otherwise the processes are similar
      i’ve set up the cors middleware to allow all origins but when i try it manually i’m told that the callback url on gitlab’s side isn’t valid

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

      @@ParacelsusCaspari Can you set the middleware to allow all origins? Does something like this help: github.com/tiangolo/fastapi/discussions/7319#discussioncomment-5135945

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

    Thank you so much, if multiple github users use this app, does github send different tokens, or everytime the same token.

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

      It’ll be a different token for each user.

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

      @@EstesAdvTech How can we refresh token without prompting to user? Can you also make a video about how security schemes work?

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

      @@alikemalagrman1067 You can use a refresh_token. See docs here: docs.github.com/en/developers/apps/building-github-apps/refreshing-user-to-server-access-tokens
      I'll see what I can do about making another long-length video for you. Is there anything specific you'd want to see?

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

    what if the token is expired?

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

      You can use a refresh token: docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens

  • @a.s8840
    @a.s8840 Рік тому

    How can I oauth with Google sign in

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

      Unfortunately I do t have much time to make new videos. But here’s a blog that might get you going: blog.hanchon.live/guides/google-login-with-fastapi/

    • @a.s8840
      @a.s8840 Рік тому

      @@EstesAdvTech this code is very old i tried but it's didn't work

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

      @@a.s8840 sorry bud. I’ll see if I can get a new video soon for this.

    • @EstesAdvTech
      @EstesAdvTech  11 місяців тому

      Just posted