Clerk.Session (Clerk SDK v1.1.0)
Session handles the JWT validation and decoding.
Usage
Clerk.Session.verify_and_validate!(jwt)
%{
"azp" => "https://example.accounts.dev",
"exp" => 1706308195,
"iat" => 1706308135,
"iss" => "https://example.clerk.accounts.dev",
"nbf" => 1706308125,
"sid" => "sess_2bVftP1rQemOu4CPj9999999999",
"sub" => "user_2bVftRtFezPdchfaz9999999999"
}
Summary
Functions
Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance
Combines generate_claims/1
and encode_and_sign/2
Same as generate_and_sign/2
but raises if error
Retrieve the details of a session
The Session object is an abstraction over an HTTP session. It models the period of information exchange between a user and the server. Sessions are created when a user successfully goes through the sign in or sign up flows.
Sets the status of a session as "revoked", which is an unauthenticated state. In multi-session mode, a revoked session will still be returned along with its client object, however the user will need to sign in again.
Combines verify/2
and validate/2
Same as verify_and_validate/2
but raises if error
Functions
create_session_from_jwt_template(session_id, jwt_template, opts \\ [])
Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance
generate_and_sign(extra_claims \\ %{}, key \\ __default_signer__())
@spec generate_and_sign(Joken.claims(), Joken.signer_arg()) :: {:ok, Joken.bearer_token(), Joken.claims()} | {:error, Joken.error_reason()}
Combines generate_claims/1
and encode_and_sign/2
generate_and_sign!(extra_claims \\ %{}, key \\ __default_signer__())
@spec generate_and_sign!(Joken.claims(), Joken.signer_arg()) :: Joken.bearer_token()
Same as generate_and_sign/2
but raises if error
get(id, opts \\ [])
Retrieve the details of a session
list(params, opts \\ [])
The Session object is an abstraction over an HTTP session. It models the period of information exchange between a user and the server. Sessions are created when a user successfully goes through the sign in or sign up flows.
https://clerk.com/docs/reference/clerkjs/session
QUERY PARAMETERS
client_id
string List sessions for the given client
user_id
string List sessions for the given user
status
string Filter sessions by the provided status
Enum: "abandoned" "active" "ended" "expired" "removed" "replaced" "revoked"
limit
number [ 1 .. 500 ] Default: 10 Applies a limit to the number of results returned. Can be used for paginating the results together with offset. Must be an integer greater than zero and less than 500. By default, if not supplied, a limit of 10 is used.
offset
number >= 0 Default: 0 Skip the first offset results when paginating. Needs to be an integer greater or equal to zero. To be used in conjunction with limit.
revoke(id, opts \\ [])
Sets the status of a session as "revoked", which is an unauthenticated state. In multi-session mode, a revoked session will still be returned along with its client object, however the user will need to sign in again.
verify_and_validate(bearer_token, key \\ __default_signer__(), context \\ %{})
@spec verify_and_validate(Joken.bearer_token(), Joken.signer_arg(), term()) :: {:ok, Joken.claims()} | {:error, Joken.error_reason()}
Combines verify/2
and validate/2
verify_and_validate!(bearer_token, key \\ __default_signer__(), context \\ %{})
@spec verify_and_validate!(Joken.bearer_token(), Joken.signer_arg(), term()) :: Joken.claims()
Same as verify_and_validate/2
but raises if error