User
eternaltwin.users.User
User(identifier: str, username: str, is_administrator: bool | None, created_at: datetime | None, deleted_at: datetime | None, token: Token | None = None)
Represents a user.
start_authorization
classmethod
Start the authorization process, returning a state and an authorization URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expiration
|
int
|
Expiration time in seconds. Default to 600 seconds. |
600
|
nonce
|
str
|
An optional nonce value used to guarantee the state to be unique. If not provided, a random one will be generated. |
None
|
using
|
str
|
The name of the connection to use, default to |
None
|
Return
tuple[str, str] The generated state and the authorization URL.
from_token
classmethod
Retrieve the user associated with the provided token.
afrom_token
async
classmethod
Retrieve the user associated with the provided token.
from_authorization_code
classmethod
from_authorization_code(authorization_code: str, callback_state: str, expected_state: str | None = None, using: str | None = None) -> Self
Retrieve the user associated with the provided authorization code.
Validate the state received from the authorization server.
An expected state can be provided to check if the state received from the authorization server matches the expected one.
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If action or authorization server does not match, the JWT is expired, or the received state does not match the expected one (if provided). |
afrom_authorization_code
async
classmethod
afrom_authorization_code(authorization_code: str, callback_state: str, expected_state: str | None = None, using: str | None = None) -> Self
Retrieve the user associated with the provided authorization code.
Validate the state received from the authorization server.
An expected state can be provided to check if the state received from the authorization server matches the expected one.
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If action or authorization server does not match, the JWT is expired, or the received state does not match the expected one (if provided). |
aget
async
classmethod
Retrieve a specific user.
search
classmethod
search(query: str | None = None, limit: int = 20, offset: int = 0, using: str | None = None) -> list[Self]
Search for users matching the query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | None
|
An optional query to use against the user's username, default to |
None
|
limit
|
int
|
The maximum number of users to return, default to |
20
|
offset
|
int
|
The offset to start returning users from, default to |
0
|
asearch
async
classmethod
asearch(query: str | None = None, limit: int = 20, offset: int = 0, using: str | None = None) -> list[Self]
Search for users matching the query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | None
|
An optional query to use against the user's username, default to |
None
|
limit
|
int
|
The maximum number of users to return, default to |
20
|
offset
|
int
|
The offset to start returning users from, default to |
0
|
count
classmethod
Search the number of users matching the query.
If query is not provided, return the total number of users.
acount
async
classmethod
Search the number of users matching the query.
If query is not provided, return the total number of users.