(oauth_applications)
- list - Get a list of OAuth applications for an instance
- create - Create an OAuth application
- get - Retrieve an OAuth application by ID
- update - Update an OAuth application
- delete - Delete an OAuth application
- rotate_secret - Rotate the client secret of the given OAuth application
This request returns the list of OAuth applications for an instance.
Results can be paginated using the optional limit
and offset
query parameters.
The OAuth applications are ordered by descending creation date.
Most recent OAuth applications will be returned first.
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.oauth_applications.list(limit=20, offset=10)
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
limit |
Optional[int] | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset . |
20 |
offset |
Optional[int] | ➖ | Skip the first offset results when paginating.Needs to be an integer greater or equal to zero. To be used in conjunction with limit . |
10 |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 400, 403, 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Creates a new OAuth application with the given name and callback URL for an instance.
The callback URL must be a valid url.
All URL schemes are allowed such as http://
, https://
, myapp://
, etc...
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.oauth_applications.create(name="Example App", callback_url="https://example.com/oauth/callback", scopes="profile email public_metadata", public=True)
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
name |
str | ✔️ | The name of the new OAuth application | Example App |
callback_url |
str | ✔️ | The callback URL of the new OAuth application | https://example.com/oauth/callback |
scopes |
Optional[str] | ➖ | Define the allowed scopes for the new OAuth applications that dictate the user payload of the OAuth user info endpoint. Available scopes are profile , email , public_metadata , private_metadata . Provide the requested scopes as a string, separated by spaces. |
profile email public_metadata |
public |
Optional[bool] | ➖ | If true, this client is public and cannot securely store a client secret. Only the authorization code flow with proof key for code exchange (PKCE) may be used. Public clients cannot be updated to be confidential clients, and vice versa. |
true |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.OAuthApplicationWithSecret
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 400, 403, 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Fetches the OAuth application whose ID matches the provided id
in the path.
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.oauth_applications.get(oauth_application_id="oauth_app_12345")
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
oauth_application_id |
str | ✔️ | The ID of the OAuth application | oauth_app_12345 |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 403, 404 | application/json |
models.SDKError | 4XX, 5XX | */* |
Updates an existing OAuth application
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.oauth_applications.update(oauth_application_id="oauth_app_67890", name="Updated OAuth App Name", callback_url="https://example.com/oauth/callback", scopes="profile email public_metadata private_metadata")
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
oauth_application_id |
str | ✔️ | The ID of the OAuth application to update | oauth_app_67890 |
name |
Optional[str] | ➖ | The new name of the OAuth application | Updated OAuth App Name |
callback_url |
Optional[str] | ➖ | The new callback URL of the OAuth application | https://example.com/oauth/callback |
scopes |
Optional[str] | ➖ | Define the allowed scopes for the new OAuth applications that dictate the user payload of the OAuth user info endpoint. Available scopes are profile , email , public_metadata , private_metadata . Provide the requested scopes as a string, separated by spaces. |
profile email public_metadata private_metadata |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 403, 404, 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Deletes the given OAuth application. This is not reversible.
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.oauth_applications.delete(oauth_application_id="oauth_app_09876")
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
oauth_application_id |
str | ✔️ | The ID of the OAuth application to delete | oauth_app_09876 |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 403, 404 | application/json |
models.SDKError | 4XX, 5XX | */* |
Rotates the OAuth application's client secret. When the client secret is rotated, make sure to update it in authorized OAuth clients.
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.oauth_applications.rotate_secret(oauth_application_id="oauth_application_12345")
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
oauth_application_id |
str | ✔️ | The ID of the OAuth application for which to rotate the client secret | oauth_application_12345 |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.OAuthApplicationWithSecret
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 403, 404 | application/json |
models.SDKError | 4XX, 5XX | */* |