Tert0 / fastapi-discord

Discord OAuth FastAPI extension for APIs
MIT License
69 stars 16 forks source link

Help please #154

Open Towux opened 1 month ago

Towux commented 1 month ago

I dont understand how to work with "Depends" Just help, how to get user info using access token? Because "Example" code dont work, it writes "Unuuthenticated" error when i do isAuthenticated, get_user and get_guilds functions maybe fastapi dont save my user in cache...

Tert0 commented 1 month ago

The easiest way to test the example is with the intrgrated FastAPI docs at http://127.0.0.1:8000

  1. Get the URL from the /login Endpoint image
  2. Use the URL from step one: Open it in a new Browser Tab and click on authorize image
  3. You should get redirected to your callback url and see your tokens like this: image
  4. Use the "Authorize" Button of the FastAPI Docs and input your access_token image image
  5. The /authenticated Endpoint should return true image
  6. You can now use the other endpoints image

If you develop a application for this you have to handle this in code. You should provide the user with a Button opening the Discord URL. When the callback is called you should save the tokens on the client and provide them on every request in the Authorization header.