Це відео не доступне.
Перепрошуємо.

Implementing OAuth 2.0 from SCRATCH

Поділитися
Вставка
  • Опубліковано 16 сер 2024

КОМЕНТАРІ • 11

  • @TheDiamondRoblox
    @TheDiamondRoblox 2 місяці тому

    Thank you! It’s something new I learned tbh ❤

  • @KossackFrank
    @KossackFrank 2 місяці тому

    Thanks, this will be very helpful, refactoring my oauth … sadly not all provided libraries are easy to use

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

    The json module has a "load" method to read a json file directly. There is no need to use either OS or Pathlib to load the json file. 😜
    # Typical usage:
    with ("secrets.json", "r") as file:
    secrets = json.load(file)

    • @Carberra
      @Carberra  2 місяці тому

      Can't one-line it though! (Well, unless you don't close it.)

    • @birdie123
      @birdie123 2 місяці тому

      ​@@Carberra Oops mistake... it should have been
      with open("secrets.json", "r") as file:
      secrets = json.load(file)

    • @yibowei9636
      @yibowei9636 2 місяці тому

      I prefer Pathlib for all file-system operations because it's a lot easier to handle exceptions, relative/absolute conversions, and most importantly one-line code for read/write operations.

    • @birdie123
      @birdie123 2 місяці тому

      @@yibowei9636 I might argue that using the "with" keyword (context manager) is more "Pythonic". 🐍🐍🐍
      If handling exception/s is required, I tend to use the following:
      try:
      with open(file, "r") as file:
      # do something
      json.load(file)
      except IOError as ioe:
      print(ioe)
      except Exception as e:
      print(e)

  • @ronalddebruijn613
    @ronalddebruijn613 2 місяці тому

    Great explanation. It will improve my access/refresh handling! I wrote an ugly selenium script to automate the authorize part. For my application the access/refresh tokens are very shortlived. Have you (or anybody) thought about automating the authorization part?

    • @Carberra
      @Carberra  2 місяці тому

      Thanks! As far as I know the authorisation part is designed specifically so it can't be automated. I don't know if anyone's managed it, but I tried once and couldn't manage it. I didn't try anything with Selenium though.

    • @ronalddebruijn613
      @ronalddebruijn613 2 місяці тому

      I think Selenium is kind of last resort to hack the unhackable. I don't think it will be resistant to changes on the website. But for now it avoids many clicks...There might me more maintable options than Selenium. But my knowledge here is limited...

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

    Dunno... It's good to learn about these things but I don't think I'd ever be comfortable writing security critical things like this myself. There's a long, careful academic / peer / deployment process the libraries go through that I just couldn't duplicate on my own. Nah, I'd never get above 99.9% confident there wasn't a hidden exploit and that's just not good enough... On this sort of thing I'm going to be risk adverse and use a library all day long.