Skip to content

Latest commit

 

History

History
89 lines (60 loc) · 9.48 KB

README.md

File metadata and controls

89 lines (60 loc) · 9.48 KB

ActorTokens

(actor_tokens)

Overview

Available Operations

create

Create an actor token that can be used to impersonate the given user. The actor parameter needs to include at least a "sub" key whose value is the ID of the actor (impersonating) user.

Example Usage

from clerk_backend_api import Clerk

with Clerk(
    bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.actor_tokens.create(user_id="user_1a2b3c", actor={}, expires_in_seconds=3600, session_max_duration_in_seconds=1800)

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description Example
user_id str ✔️ The ID of the user being impersonated. user_1a2b3c
actor models.CreateActorTokenActor ✔️ The actor payload. It needs to include a sub property which should contain the ID of the actor.
This whole payload will be also included in the JWT session token.
{
"sub": "user_2OEpKhcCN1Lat9NQ0G6puh7q5Rb"
}
expires_in_seconds Optional[int] Optional parameter to specify the life duration of the actor token in seconds.
By default, the duration is 1 hour.
3600
session_max_duration_in_seconds Optional[int] The maximum duration that the session which will be created by the generated actor token should last.
By default, the duration of a session created via an actor token, lasts 30 minutes.
1800
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ActorToken

Errors

Error Type Status Code Content Type
models.ClerkErrors 400, 402, 422 application/json
models.SDKError 4XX, 5XX */*

revoke

Revokes a pending actor token.

Example Usage

from clerk_backend_api import Clerk

with Clerk(
    bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.actor_tokens.revoke(actor_token_id="act_tok_abcdefghijk")

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description Example
actor_token_id str ✔️ The ID of the actor token to be revoked. act_tok_abcdefghijk
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ActorToken

Errors

Error Type Status Code Content Type
models.ClerkErrors 400, 404 application/json
models.SDKError 4XX, 5XX */*