Client Side Requests
- class discord.ext.oauth.client.OAuth2Client(*, client_id: int, client_secret: str, redirect_uri: str, scopes: Optional[List[str]] = None)
A class representing a client interacting with the discord OAuth2 API.
- await close()
Closes and performs cleanup operations on the client, such as clearing its cache.
- await exchange_code(code: str) discord.ext.oauth.token.AccessTokenResponse
Exchanges the code you receive from the OAuth2 redirect.
- Parameters
code (str) – The code you’ve received from the OAuth2 redirect
- Returns
A response class containing information about the access token
- Return type
- await fetch_user(access_token_response: discord.ext.oauth.token.AccessTokenResponse) discord.ext.oauth.user.User
Makes an api call to fetch a user using their access token.
- Parameters
access_token_response (AccessTokenResponse) – A class holding information about an access token
- Returns
Returns a User object holding information about the select user
- Return type
- get_user(id: int) Optional[discord.ext.oauth.user.User]
Gets a user from the cache. The cache is a WeakValueDictionary, so objects may be removed without notice.
- Parameters
id (int) – The id of the user you want to get
- Returns
A possible user object. Returns None if no User is found in cache.
- Return type
Optional[User]
- await refresh_token(refresh_token: Union[str, discord.ext.oauth.token.AccessTokenResponse]) discord.ext.oauth.token.AccessTokenResponse
Refreshes an access token. Takes either a string or an AccessTokenResponse.
- Parameters
refresh_token (Union[str, AccessTokenResponse]) – The refresh token you received when exchanging a redirect code
- Returns
A new access token response containg information about the refreshed access token
- Return type