(oauth2)
- authorize - Authorize
- token - Request Token
- revoke - Revoke Token
- introspect - Introspect Token
- userinfo - Get User Info
Authorize
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.oauth2.authorize()
# Handle response
print(res)models.Oauth2AuthorizeResponseOauth2Authorize
| Error Type | Status Code | Content Type |
|---|---|---|
| models.SDKError | 4XX, 5XX | */* |
Request an access token using a valid grant.
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)| 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. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.SDKError | 4XX, 5XX | */* |
Revoke an access token or a refresh token.
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)| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.RevokeTokenRequest | ✔️ | The request object to use for the request. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.SDKError | 4XX, 5XX | */* |
Get information about an access token.
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)| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.IntrospectTokenRequest | ✔️ | The request object to use for the request. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.IntrospectTokenResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models.SDKError | 4XX, 5XX | */* |
Get information about the authenticated user.
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.oauth2.userinfo()
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.Oauth2UserinfoResponseOauth2Userinfo
