Oauth2
August 12, 2025 ยท View on GitHub
(oauth2)
Overview
Available Operations
- authorize - Authorize
- token - Request Token
- revoke - Revoke Token
- introspect - Introspect Token
- userinfo - Get User Info
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
| Parameter | Type | Required | Description |
|---|---|---|---|
retries | Optional[utils.RetryConfig] | :heavy_minus_sign: | 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
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
| Parameter | Type | Required | Description |
|---|---|---|---|
request | models.Oauth2RequestTokenRequestBody | :heavy_check_mark: | The request object to use for the request. |
retries | Optional[utils.RetryConfig] | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
Response
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() as polar:
res = polar.oauth2.revoke(request={
"token": "<value>",
"client_id": "<id>",
"client_secret": "<value>",
})
# Handle response
print(res)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | models.RevokeTokenRequest | :heavy_check_mark: | The request object to use for the request. |
retries | Optional[utils.RetryConfig] | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
Response
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() as polar:
res = polar.oauth2.introspect(request={
"token": "<value>",
"client_id": "<id>",
"client_secret": "<value>",
})
# Handle response
print(res)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | models.IntrospectTokenRequest | :heavy_check_mark: | The request object to use for the request. |
retries | Optional[utils.RetryConfig] | :heavy_minus_sign: | 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 polar:
res = polar.oauth2.userinfo()
# Handle response
print(res)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
retries | Optional[utils.RetryConfig] | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
Response
models.Oauth2UserinfoResponseOauth2Userinfo
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| models.SDKError | 4XX, 5XX | */* |