Skip to content

jam.oauth2.__abc_oauth2_repo__

__abc_oauth2_repo__

Classes:

Name Description
BaseOAuth2Client

Base OAuth2 client instance.

BaseOAuth2Client

BaseOAuth2Client(
    client_id: str,
    client_secret: str,
    auth_url: str,
    token_url: str,
    redirect_url: str,
)

Bases: ABC

Base OAuth2 client instance.

Parameters:

Name Type Description Default
client_id str

ID or your client

required
client_secret str

Secret key for your application

required
auth_url str

App auth url

required
token_url str

App token url

required
redirect_url str

Your app url

required

Methods:

Name Description
client_credentials_flow

Obtain access token using client credentials flow (no user interaction).

fetch_token

Exchange code for access token.

get_authorization_url

Get OAuth2 url.

refresh_token

Update access token.

client_credentials_flow abstractmethod

client_credentials_flow(
    scope: Optional[list[str]] = None,
) -> dict[str, Any]

Obtain access token using client credentials flow (no user interaction).

Parameters:

Name Type Description Default
scope Optional[list[str]]

Auth scope

None

Returns:

Name Type Description
dict dict[str, Any]

JSON with access token

fetch_token abstractmethod

fetch_token(code: str) -> str

Exchange code for access token.

Parameters:

Name Type Description Default
code str

Auth code

required

Returns:

Name Type Description
str str

Access token

get_authorization_url abstractmethod

get_authorization_url(scope: list[str]) -> str

Get OAuth2 url.

Parameters:

Name Type Description Default
scope list[str]

Auth scope

required

Returns:

Name Type Description
str str

URL for auth

refresh_token abstractmethod

refresh_token(refresh_token: str) -> str

Update access token.

Parameters:

Name Type Description Default
refresh_token str

Refresh token

required

Returns:

Name Type Description
str str

New access token

__BaseOAuth2Server

__BaseOAuth2Server(
    app_url: str,
    code_factory: Callable[[], str] = lambda: token_urlsafe(
        8
    ),
)

Bases: ABC

Base OAuth2 server instance.

Parameters:

Name Type Description Default
app_url str

URL of your app

required
code_factory Callable[[], str]

Factory for code generation

lambda: token_urlsafe(8)

FILE PATH: jam/oauth2/__abc_oauth2_repo__.py