Oauth2Access
Represents a Discord oauth2 access object, what is returned by Client.activate_authorization_code
if activating the authorization code went successfully.
Attributes
str
Token used for Bearer
authorizations, when requesting OAuth2 data about the respective user.
DateTime
The time when the access was last created or renewed.
int
The time in seconds after this access expires.
str
The redirect url with what the user granted the authorization code for the oauth2 scopes for the application.
Can be empty string if application's owner's access was requested.
str
The token used to renew the access token.
Can be empty string if application's owner's access was requested.
A sequence of the scopes, which the user granted with the access token.
Defaults to None
if empty.
Properties
expires_at
Returns when the access expires.
Returns
expires_at : DateTime
Methods
(...)
__new__Creates a new oauth2 access with the given fields.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
access_token |
| Token used for | ||
created_at |
| The time when the access was last created or renewed. | ||
expires_after |
| The time in seconds after this access expires. | ||
redirect_url |
| The redirect url with what the user granted the authorization code for the oauth2 scopes for the application. | ||
refresh_token |
| The token used to renew the access token. | ||
scopes |
| A sequence of the scopes, which the user granted with the access token. |
Raises
TypeError
- If a parameter's type is incorrect.
ValueError
- If a parameter's value is incorrect.
()
copyCopies the oauth2 access.
Returns
new : instance<type<self>
(...)
copy_withCopies the oauth2 scopes with the given fields.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
access_token |
| Token used for | ||
created_at |
| The time when the access was last created or renewed. | ||
expires_after |
| The time in seconds after this access expires. | ||
redirect_url |
| The redirect url with what the user granted the authorization code for the oauth2 scopes for the application. | ||
refresh_token |
| The token used to renew the access token. | ||
scopes |
| A sequence of the scopes, which the user granted with the access token. |
Returns
new : instance<type<self>
Raises
TypeError
- If a parameter's type is incorrect.
ValueError
- If a parameter's value is incorrect.
(data, redirect_url)
from_dataCreates an Oauth2Access
.
Parameter | Type | Description |
---|---|---|
data |
| Received access data. |
redirect_url |
| The redirect url with what the user granted the authorization code for the oauth2 scopes for the application. |
Returns
self : instance<cls>
(scope)
has_scopeReturns whether the access has the given scope.
Parameter | Type | Description |
---|---|---|
scope |
| The scope to check out. |
Returns
has_scope : bool
Raises
TypeError
- If
scope
is neitherstr
,Oauth2Scope
.
()
iter_scopesIterates over the oauth2 scopes of the oauth2 access.
This method is an iterable generator.
Yields
scope : Oauth2Scope
(...)
to_dataConverts the access to a json serializable object.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
defaults |
|
| Whether fields with their default value should be included as well. |
Returns
data : dict
of (str
, object
) items
(data)
_renewRenews the access with the given data.
Parameter | Type | Description |
---|---|---|
data |
| Requested access data. |
()
__eq__Returns whether the two oauth2 access are equal.
()
__getattr__Drops a rich attribute error.
()
__hash__Returns the oauth2 scope's hash value.
()
__repr__Returns the representation of the oath2 access.