@oauth
Overview
The @oauth
decorator is used to apply OAuth-based authentication to classes. It adds OAuth-specific metadata, such as endpoints, arguments, and provider details, to the class, enabling integration with OAuth services.
Syntax
@oauth(
id=str,
provider=OAuthProvider,
flows=Optional[List[OAuthFlow]] = None,
authorize_endpoint=str,
token_endpoint=str,
scopes=Optional[List[str]] = None,
)
class ClassName:
"""
Class description
"""
# Class implementation
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
| str | Yes | The unique identifier for the OAuth configuration. |
| Yes | The OAuth provider:
| |
| List[OAuthFlow] | Optional | A list of OAuth flows. |
| str | Yes | The authorization endpoint URL for the OAuth provider. |
| str | Yes | The token endpoint URL for exchanging the authorization code for a token. |
| List[str] | Optional | A list of scopes required by the OAuth provider for the authenticated requests. |
Example
@oauth(
id="oauth",
provider=OAuthProvider.MICROSOFT,
flows=[OAuthFlow.AUTHORIZATION_CODE],
authorize_endpoint="https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/authorize",
token_endpoint="https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token",
scopes=[
"https://graph.microsoft.com/Files.ReadWrite",
"https://graph.microsoft.com/Sites.ReadWrite.All",
],
)
@book(name="MicrosoftBook")
class BaseMicrosoftBook
Updated about 1 month ago
What’s Next