Authentication¶
JWT auth: acquire and persist scoped access tokens via get_token().
get_token(email, password, scopes=('user',), *, base_url=None, api_path=None, config_file=None, save_token=True)
¶
Obtain a JWT access token via email/password credentials.
Configuration is resolved from three sources in priority order
(highest to lowest): code-level arguments → ineepy.toml in the
current directory → INEEPY_* environment variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
User email address. |
required |
password
|
str
|
User password. |
required |
scopes
|
str | Iterable[str]
|
Scope name, or an iterable of scope names, to request.
Defaults to |
('user',)
|
base_url
|
str | None
|
API base URL. Defaults to config/env |
None
|
api_path
|
str | None
|
API path prefix. Defaults to config/env |
None
|
config_file
|
str | Path | None
|
Path to the TOML config file (str or Path). Defaults
to |
None
|
save_token
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The access token string. When |
str
|
written to |
Raises:
| Type | Description |
|---|---|
ValidationError
|
The server rejected the credentials, or the response did not contain an access token. |
ForbiddenError
|
The requested scopes exceed what the account is allowed. |
Example::
token = get_token('me@example.com', 'password', save_token=False)
async_get_token(email, password, scopes=('user',), *, base_url=None, api_path=None, config_file=None, save_token=True)
async
¶
Async version of :func:get_token.