(actorTokens())
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.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.Actor;
import com.clerk.backend_api.models.operations.CreateActorTokenRequestBody;
import com.clerk.backend_api.models.operations.CreateActorTokenResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
CreateActorTokenRequestBody req = CreateActorTokenRequestBody.builder()
.userId("<id>")
.actor(Actor.builder()
.build())
.build();
CreateActorTokenResponse res = sdk.actorTokens().create()
.request(req)
.call();
if (res.actorToken().isPresent()) {
// handle response
}
}
}
CreateActorTokenResponse
Error Type |
Status Code |
Content Type |
models/errors/ClerkErrors |
400, 402, 422 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |
Revokes a pending actor token.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.RevokeActorTokenResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
RevokeActorTokenResponse res = sdk.actorTokens().revoke()
.actorTokenId("<id>")
.call();
if (res.actorToken().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
actorTokenId |
String |
✔️ |
The ID of the actor token to be revoked. |
RevokeActorTokenResponse
Error Type |
Status Code |
Content Type |
models/errors/ClerkErrors |
400, 404 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |