Oauth2

August 12, 2025 ยท View on GitHub

(oauth2)

Overview

Available Operations

authorize

Authorize

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.oauth2.authorize()

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Oauth2AuthorizeResponseOauth2Authorize

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*

token

Request an access token using a valid grant.

Example Usage

from polar_sdk import Polar


with Polar() as polar:

    res = polar.oauth2.token(request={
        "grant_type": "authorization_code",
        "client_id": "<id>",
        "client_secret": "<value>",
        "code": "<value>",
        "redirect_uri": "https://memorable-season.name",
    })

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
requestmodels.Oauth2RequestTokenRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.TokenResponse

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*

revoke

Revoke an access token or a refresh token.

Example Usage

from polar_sdk import Polar


with Polar() as polar:

    res = polar.oauth2.revoke(request={
        "token": "<value>",
        "client_id": "<id>",
        "client_secret": "<value>",
    })

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
requestmodels.RevokeTokenRequest:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.RevokeTokenResponse

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*

introspect

Get information about an access token.

Example Usage

from polar_sdk import Polar


with Polar() as polar:

    res = polar.oauth2.introspect(request={
        "token": "<value>",
        "client_id": "<id>",
        "client_secret": "<value>",
    })

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
requestmodels.IntrospectTokenRequest:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.IntrospectTokenResponse

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*

userinfo

Get information about the authenticated user.

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.oauth2.userinfo()

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Oauth2UserinfoResponseOauth2Userinfo

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*