LogoLogo
About
  • Home
  • Guides
  • BDK
  • REST API
  • BDK Overview
  • Planning Guide
  • Setup Guide
  • Development Guide
  • Deployment
  • Learning a BDK Book
  • Connection Commands
  • BDK API Reference
    • Concepts
    • Connections
    • Decorators
      • @book
      • @concept
      • @config
      • @connect
      • @oauth
      • @oauthtoken
      • @procedure
    • Docstrings
    • Enums
      • FilterBinaryOperator
      • FilterUnaryOperator
    • Filter Expressions
    • Noun Phrases
    • Procedures
Powered by GitBook
On this page
  • Overview
  • Syntax
  • Parameters
  • Example

Was this helpful?

Export as PDF
  1. BDK API Reference
  2. Decorators

@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

id

str

Yes

The unique identifier for the OAuth configuration.

provider

Yes

The OAuth provider:

  • OAuthProvider.MICROSOFT

  • OAuthProvider.GOOGLE

flows

Optional

A list of OAuth flows.

authorize_endpoint

str

Yes

The authorization endpoint URL for the OAuth provider.

token_endpoint

str

Yes

The token endpoint URL for exchanging the authorization code for a token.

scopes

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

Last updated 1 month ago

Was this helpful?

List[]

OAuthProvider
OAuthFlow