fastapi-discord icon indicating copy to clipboard operation
fastapi-discord copied to clipboard

Help please

Open Towux opened this issue 1 year ago • 1 comments

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...

Towux avatar Aug 06 '24 14:08 Towux

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.

Tert0 avatar Aug 06 '24 22:08 Tert0