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
(redirect_url, code, scopes)
activate_authorization_codeActivates a user's oauth2 code.
This method is a coroutine.
Parameter | Type | Description |
---|---|---|
redirect_url |
| The url, where the activation page redirected to. |
code |
| The code, what is included with the redirect url after a successful activation. |
scopes |
| 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, access, ...)
guild_user_addAdds the passed to the guild. The user must have granted you the 'guilds.join'
oauth2 scope.
This method is a coroutine.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
guild |
| The guild, where the user is going to be added. | |||
access |
| The access of the user, who will be added. | |||
user |
| None | Defines which user will be added to the guild. The This field is optional if access is passed as an | ||
nick |
|
| The nickname, which with the user will be added. | ||
roles |
|
| The roles to add the user with. | ||
mute |
|
| Whether the user should be added as muted. | ||
deaf |
|
| Whether the user should be added as deafen. |
Raises
TypeError:
- If
user
was not given neither asNone
,ClientUserBase
,int
. - If
user
was passed asNone
andaccess
was passed asOauth2Access
,str
. - If
access
was not given asOauth2Access
,Oauth2User
, nether asstr
. - If the given
access
not grants'guilds.join'
scope. - If
guild
was not given neither asGuild
, notint
. - If
roles
contain notRole
, norint
.
ValueError
- If the given
access
is not providing the required scope. - If
user
andaccess
refers to a different user.
ConnectionError
No internet connection.
DiscordException
If any exception was received from the Discord API.
(scopes)
owners_accessSimilar 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.
Parameter | Type | Description |
---|---|---|
scopes |
| 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 asstr
. - If
code
was not given asstr
. - If
scopes
is empty. - If
scopes
contains empty string.
Notes
Does not work if the client's application is owned by a team.
(access)
renew_access_tokenRenews the access token of an Oauth2Access
.
This method is a coroutine.
Parameter | Type | Description |
---|---|---|
access | Oauth2 access to the respective user. |
Raises
TypeError
- If
access
is notOauth2Access
,Oauth2User
.
ConnectionError
No internet connection.
DiscordException
If any exception was received from the Discord API.
Notes
By default access tokens expire after one week.
(access, ...)
user_application_role_connection_editEdits 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.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
access |
| The access of the user, who will's application role connections will be requested.. | |||
application_role_connection_template |
| 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 |
| The vanity name of the platform the application represents. | |||
platform_user_name |
| The name of the user on the application's platform. | |||
metadata_values |
| Metadata key to attached value relation. |
Returns
application_role_connection : ApplicationRoleConnection
Raises
TypeError
- If
access
is notOauth2Access
,Oauth2User
,str
.
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.
(access)
user_application_role_connection_getRequests 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.
Parameter | Type | Description |
---|---|---|
access |
| The access of the user, who will's application role connections will be requested.. |
Returns
application_role_connection : ApplicationRoleConnection
Raises
TypeError
- If
access
is notOauth2Access
,Oauth2User
,str
.
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.
(access)
user_connection_get_allRequests 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.
Parameter | Type | Description |
---|---|---|
access |
| Oauth2 access to the respective user or it's access token. |
Returns
connections : list
of Connection
The user's connections.
Raises
TypeError
- If
access
is notOauth2Access
,Oauth2User
,str
.
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.
(access)
user_guild_get_allRequests 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.
Parameter | Type | Description |
---|---|---|
access |
| 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
- If
access
is notOauth2Access
,Oauth2User
,str
.
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.
(access)
user_info_getRequest 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.
Parameter | Type | Description |
---|---|---|
access |
| Oauth2 access to the respective user or it's access token. |
Returns
oauth2_user : Oauth2User
The requested user object.
Raises
TypeError
- If
access
is notOauth2Access
,Oauth2User
,str
.
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