🔐 OAuth#
Client#
- class OAuthClient(*, client_id, client_secret, base_url='https://exbo.net/oauth', redirect_uri='http://localhost', scope='', json=False)[source]#
Bases:
APIClientAPI Client for OAuth 2.0 authentication with EXBO services.
- get_authorize_url(state=None, redirect_uri=None, scope=None)[source]#
Generate user authorization URL.
- Parameters:
state (optional) – CSRF protection state string.
redirect_uri (optional) – Override default redirect URI.
scope (optional) – Override default scope.
- Return type:
str- Returns:
URL for user authorization.
- async get_app_token(scope=None)[source]#
Request application token using client credentials grant.
NOTE: New tokens replace and invalidate previous ones.
- Parameters:
scope (optional) – Override default scope.
- Return type:
- Returns:
Application token data.
- async get_user_token(code)[source]#
Exchange authorization code for user token.
NOTE: New tokens replace and invalidate previous ones.
- Parameters:
code (
str) – Authorization code from user redirect.- Return type:
- Returns:
User token data with access and refresh token.
Models#
- class OAuthModel(**data)[source]#
Bases:
BaseModelBase model for OAuth response data.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class TokenResponse(**data)[source]#
Bases:
OAuthModelBase token response.
-
token_type:
str#
-
access_token:
str#
-
expires_in:
datetime#
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
token_type:
- class AppToken(**data)[source]#
Bases:
TokenResponseApplication access token.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class UserToken(**data)[source]#
Bases:
TokenResponseUser access and refresh token.
-
refresh_token:
str#
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
refresh_token:
- class UserInfo(**data)[source]#
Bases:
OAuthModelEXBO account information.
-
id:
int#
-
uuid:
UUID#
-
login:
str#
-
display_login:
Optional[str]#
-
distributor:
str#
-
distributor_id:
Optional[str]#
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
id: