Quickstart#
I’ll include some example apps on a different page
Before we can get the oauth url, we need to install and setup DiscoAuth
Installation#
To use DiscoAuth, you need to first install it using pip:
(.venv) $ pip install discoauth
Now it’s time to get started
Access Token#
We’ll need to uses a different class to get the token. Now let’s go and add discord to the import statement:
from discoauth import auth, discord
Now, we need a new variable, client_secret. Which is your app’s client secret.
using the other three variables and client_secret we can use discord.
api = discord(client_id, client_secret, scope, redirect_uri)
r = await api.token(code)
token = r['access_token']
Now, token is your access token. Save this somewhere safe.
Remember, token() returns a dictionary, containing the entire response, so you can still get the refresh_token
User Data#
Now it’s time to get the user data! We can use the subclass user to get user data.:
r = await discord.user(token).fetch()
After the fetch() you will get a response(r), which is an object-turned-dictionary, based off of the Discord User Object
The end… ?#
Hooray! Now we can get the username and avatar
While this is the end of the guides for this version, more will come later
And if you can’t wait, make sure to visit the API reference.