ClientCompoundOauth2Endpoints

Methods

__new__()

Compound components do not support instancing.

Sub-typing is supported, but the attributes are only proxied. Sub-types have no meaning by themselves.

Raises

RuntimeError

activate_authorization_code(redirect_url, code, scopes)

Activates a user's oauth2 code.

This method is a coroutine.

ParameterTypeDescription
redirect_url

str

The url, where the activation page redirected to.

code

str

The code, what is included with the redirect url after a successful activation.

scopes

str, list of str

Scope or a list of oauth2 scopes to request.

Returns

access : Oauth2Access, None

If the code, the redirect url or the scopes are invalid, the methods returns None.

Raises

TypeError

If Scopes wasn't neither as str not list of str s.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

See Also

parse_oauth2_redirect_url: Parses redirect_url and the code from a full url.

guild_user_add(guild, access, ...)

Adds the passed to the guild. The user must have granted you the 'guilds.join' oauth2 scope.

This method is a coroutine.

ParameterTypeOptionalKeyword onlyDefaultDescription
guild

Guild, int

The guild, where the user is going to be added.

access

Oauth2Access, Oauth2User, str

The access of the user, who will be added.

user

None, ClientUserBase

None , int

Defines which user will be added to the guild. The access must refer to this specified user.

This field is optional if access is passed as an Oauth2User object.

nick

None, str

None

The nickname, which with the user will be added.

roles

None, list of (Role, int)

None

The roles to add the user with.

mute

bool

False

Whether the user should be added as muted.

deaf

bool

False

Whether the user should be added as deafen.

Raises

TypeError:

  • If user was not given neither as None, ClientUserBase, int.
  • If user was passed as None and access was passed as Oauth2Access, str.
  • If access was not given as Oauth2Access, Oauth2User, nether as str.
  • If the given access not grants 'guilds.join' scope.
  • If guild was not given neither as Guild, not int.
  • If roles contain not Role, nor int.

ValueError

  • If the given access is not providing the required scope.
  • If user and access refers to a different user.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

owners_access(scopes)

Similar to .activate_authorization_code, but it requests the application's owner's access. It does not requires the redirect_url and the code parameter either.

This method is a coroutine.

ParameterTypeDescription
scopes

list of str

A list of oauth2 scopes to request.

Returns

access : Oauth2Access

The oauth2 access of the client's application's owner.

Raises

TypeError

If Scopes is neither str nor list of str s.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

AssertionError

  • If redirect_url was not given as str.
  • If code was not given as str.
  • If scopes is empty.
  • If scopes contains empty string.

Notes

Does not work if the client's application is owned by a team.

renew_access_token(access)

Renews the access token of an Oauth2Access.

This method is a coroutine.

ParameterTypeDescription
access

Oauth2Access, Oauth2User

Oauth2 access to the respective user.

Raises

TypeError

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

Notes

By default access tokens expire after one week.

user_application_role_connection_edit(access, ...)

Edits a user's application role connections with it's Oauth2Access. The user must provide the Oauth2Scope.role_connections_write scope for this request to succeed.

This method is a coroutine.

ParameterTypeOptionalKeyword onlyDefaultDescription
access

Oauth2Access, Oauth2User, str

The access of the user, who will's application role connections will be requested..

application_role_connection_template

None, ApplicationRoleConnection

None

Application role connection to use as a template.

**keyword_parameters

Keyword parameters

Additional keyword parameters either to define the template, or to overwrite specific fields' values.

platform_name

None, str

The vanity name of the platform the application represents.

platform_user_name

None, str

The name of the user on the application's platform.

metadata_values

None, dict of (str, str) items

Metadata key to attached value relation.

Returns

application_role_connection : ApplicationRoleConnection

Raises

TypeError

ValueError

  • If the given access is not providing the required scope.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

user_application_role_connection_get(access)

Requests a user's application role connections with it's Oauth2Access. The user must provide the Oauth2Scope.role_connections_write scope for this request to succeed.

This method is a coroutine.

ParameterTypeDescription
access

Oauth2Access, Oauth2User, str

The access of the user, who will's application role connections will be requested..

Returns

application_role_connection : ApplicationRoleConnection

Raises

TypeError

ValueError

  • If the given access is not providing the required scope.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

user_connection_get_all(access)

Requests a user's connections. This method will work only if the access token has the 'connections' scope. At the returned list includes the user's hidden connections as well.

This method is a coroutine.

ParameterTypeDescription
access

Oauth2Access, Oauth2User, str

Oauth2 access to the respective user or it's access token.

Returns

connections : list of Connection

The user's connections.

Raises

TypeError

ValueError

  • If the given access is not providing the required scope.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

user_guild_get_all(access)

Requests a user's guilds with it's Oauth2Access. The user must provide the Oauth2Scope.guilds scope for this request to succeed.

This method is a coroutine.

ParameterTypeDescription
access

Oauth2Access, Oauth2User, str

The access of the user, who's guilds will be requested.

Returns

guilds_and_permissions : list of tuple(Guild, UserGuildPermission)

The guilds and the user's permissions in each of them. Not loaded guilds will show up as partial ones.

Raises

TypeError

ValueError

  • If the given access is not providing the required scope.

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

user_info_get(access)

Request the a user's information with oauth2 access token. By default a bot account should be able to request every public information about a user (but you do not need oauth2 for that). If the access token has email or/and identify scopes, then more information should show up like this.

This method is a coroutine.

ParameterTypeDescription
access

Oauth2Access, Oauth2User, str

Oauth2 access to the respective user or it's access token.

Returns

oauth2_user : Oauth2User

The requested user object.

Raises

TypeError

ConnectionError

No internet connection.

DiscordException

If any exception was received from the Discord API.

Notes

Needs 'email' or / and 'identify' scopes granted for more data