Skip to content

Latest commit

 

History

History
210 lines (142 loc) · 9.9 KB

README.md

File metadata and controls

210 lines (142 loc) · 9.9 KB

Oauth2

(oauth2)

Overview

Available Operations

authorize

Authorize

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.oauth2.authorize()

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Oauth2AuthorizeResponseOauth2Authorize

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*

token

Request an access token using a valid grant.

Example Usage

import polar_sdk
from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.oauth2.token(request={
        "client_id": "<id>",
        "client_secret": "<value>",
        "code": "<value>",
        "redirect_uri": "https://old-fort.name",
        "grant_type": polar_sdk.GrantType.AUTHORIZATION_CODE,
    })

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.Oauth2RequestTokenRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.TokenResponse

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*

revoke

Revoke an access token or a refresh token.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.oauth2.revoke(request={
        "token": "<value>",
        "client_id": "<value>",
        "client_secret": "<value>",
    })

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.Oauth2RevokeTokenRevokeTokenRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.RevokeTokenResponse

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*

introspect

Get information about an access token.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.oauth2.introspect(request={
        "token": "<value>",
        "client_id": "<value>",
        "client_secret": "<value>",
    })

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.Oauth2IntrospectTokenIntrospectTokenRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.IntrospectTokenResponse

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*

userinfo

Get information about the authenticated user.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.oauth2.userinfo()

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Oauth2UserinfoResponseOauth2Userinfo

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*