Skip to content

Latest commit

 

History

History
115 lines (79 loc) · 4.47 KB

README.md

File metadata and controls

115 lines (79 loc) · 4.47 KB

SignInTokens

(signInTokens())

Overview

Available Operations

  • create - Create sign-in token
  • revoke - Revoke the given sign-in token

create

Creates a new sign-in token and associates it with the given user. By default, sign-in tokens expire in 30 days. You can optionally supply a different duration in seconds using the expires_in_seconds property.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.CreateSignInTokenRequestBody;
import com.clerk.backend_api.models.operations.CreateSignInTokenResponse;
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();

        CreateSignInTokenRequestBody req = CreateSignInTokenRequestBody.builder()
                .build();

        CreateSignInTokenResponse res = sdk.signInTokens().create()
                .request(req)
                .call();

        if (res.signInToken().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
request CreateSignInTokenRequestBody ✔️ The request object to use for the request.

Response

CreateSignInTokenResponse

Errors

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

revoke

Revokes a pending sign-in token

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.RevokeSignInTokenResponse;
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();

        RevokeSignInTokenResponse res = sdk.signInTokens().revoke()
                .signInTokenId("<id>")
                .call();

        if (res.signInToken().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
signInTokenId String ✔️ The ID of the sign-in token to be revoked

Response

RevokeSignInTokenResponse

Errors

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