AccessToken
- class discordoauth2.AccessToken
- client
The client which generated this AccessToken
- Type:
- token
The raw token for this AccessToken, you can use
discordoauth2.Client.from_access_tokento use it again.- Type:
- refresh_token
The refresh_token for this AccessToken, you can use
discordoauth2.Client.refresh_tokento use this authorization again after it expires.- Type:
- webhook
A parital webhook object if they was a
webhook.incomingscope.- Type:
- guild
A partial guild object if a bot was added to a guild.
- Type:
- fetch_identify()
Returns a dictionary with a user object which includes
emailandverified(verified email) if theemailscope is provided- Returns:
- Raises:
discordoauth2.exceptions.HTTPException – The request failed
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the identify scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- fetch_connections()
Returns a list of connection objects
- Returns:
- Raises:
discordoauth2.exceptions.HTTPException – The request failed
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the connections scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- fetch_guilds()
Returns a list of partial guild objects
- Returns:
- Raises:
discordoauth2.exceptions.HTTPException – The request failed
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- fetch_guild_member(guild_id)
Returns a partial guild member object
- Parameters:
guild_id (int) – The guild ID to retrieve member data from.
- Returns:
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- join_guild(guild_id, nick=None, role_ids=None, mute=False, deaf=False)
Adds the user to a guild. The application’s bot must also be in the guild, have invite permissions and it’s bot token must also be provided.
- Parameters:
guild_id (int) – The guild ID to retrieve member data from.
nick (str) – The nickname the member should have when they join.
role_ids (list[int]) – a List of role IDs to assign them when they join.
mute (bool) – Wether they should be server muted when they join.
deaf (bool) – Wether they should be server deafend when they join.
- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.join scope or the bot isn’t in the guild/have the correct permissions.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
Note
The bot token is required to join guilds, and it must have
CREATE_INSTANT_INVITEin the target server.- fetch_metadata()
Returns the user’s metadata object for this application.
New in version 1.1.
- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- update_metadata(platform_name=None, username=None, **metadata)
Updates and returns the user’s metadata object for this application.
New in version 1.1.
- Parameters:
platform_name (str) – Text that appears at the top of the app connection box, usally denoting the platform’s name.
platform_username (str) – Text that appears under the platform name, large, and usally denoting the user’s name on the platform.
metadata (dict) – List of keys and values to set the user’s metadata. Supported types:
bool,datetime.datetime,int
- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
Warning
You must make sure to store the access token and refresh token, otherwise you won’t be able to update or remove the metadata later.
- clear_metadata()
Removes the user’s metadata object for this application.
New in version 1.1.
- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- revoke()
Shorthand for
Client.revoke_token(), it will revoke the access token and any related refresh token.New in version 1.1.
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- revoke_refresh_token()
Shorthand for
Client.revoke_token(), it will revoke the refresh token and any related access token.New in version 1.1.
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- class discordoauth2.PartialAccessToken
- client
The client which generated this AccessToken
- Type:
- token
The raw token for this AccessToken, you can use
discordoauth2.Client.from_access_tokento use it again.- Type:
- fetch_identify()
Returns a dictionary with a user object which includes
emailandverified(verified email) if theemailscope is provided- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the identify scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- fetch_connections()
Returns a list of connection objects
- Returns:
list[dict]
- Raises:
discordoauth2.exceptions.HTTPException – The request failed
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the connections scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- fetch_guilds()
Returns a list of partial guild objects
- Returns:
list[dict]
- Raises:
discordoauth2.exceptions.HTTPException – The request failed
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- fetch_guild_member(guild_id)
Returns a partial guild member object
- Parameters:
guild_id (int) – The guild ID to retrieve member data from.
- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- join_guild(guild_id, nick=None, role_ids=None, mute=False, deaf=False)
Adds the user to a guild. The application’s bot must also be in the guild, have invite permissions and it’s bot token must also be provided.
- Parameters:
guild_id (int) – The guild ID to retrieve member data from.
nick (str) – The nickname the member should have when they join.
role_ids (list[int]) – a List of role IDs to assign them when they join.
mute (bool) – Wether they should be server muted when they join.
deaf (bool) – Wether they should be server deafend when they join.
- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.join scope or the bot isn’t in the guild/have the correct permissions.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- fetch_metadata()
Returns the user’s metadata object for this application.
New in version 1.1.
- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- update_metadata(platform_name=None, username=None, **metadata)
Updates and returns the user’s metadata object for this application.
New in version 1.1.
- Parameters:
platform_name (str) – Text that appears at the top of the app connection box, usally denoting the platform’s name.
platform_username (str) – Text that appears under the platform name, large, and usally denoting the user’s name on the platform.
metadata (dict) – List of keys and values to set the user’s metadata. Supported types:
bool,datetime.datetime,int
- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
Warning
You must make sure to store the access token and refresh token, otherwise you won’t be able to update or remove the metadata later.
- clear_metadata()
Removes the user’s metadata object for this application.
New in version 1.1.
- Returns:
dict
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.
- revoke()
Shorthand for
Client.revoke_token(), it will revoke the access token and any related refresh token.New in version 1.1.
- Raises:
discordoauth2.exceptions.HTTPException – The request failed, possibly because the member is not in the guild.
discordoauth2.exceptions.Forbidden – The AccessToken doesn’t have the guilds.member.read scope.
discordoauth2.exceptions.RateLimited – You’re being rate limited.