Search documentation of ExStreamClient

# ExStreamClient.Token.Server (ExStreamClient v0.1.10)

View Source

# Summary

## Functions

generate_and_sign(extra_claims \\ %{}, key \\ __default_signer__())

Combines `generate_claims/1` and `encode_and_sign/2`

generate_and_sign!(extra_claims \\ %{}, key \\ __default_signer__())

Same as `generate_and_sign/2` but raises if error

get()

Gets a server token using the default API key from config. Tokens are cached per API key to avoid regenerating them unnecessarily.

get(key, secret)

Gets a server token for the specified API key and API key secret. Tokens are cached per API key to avoid regenerating them unnecessarily.

signer()

Returns the signer used for server tokens.

signer(secret)

Returns the signer used for server tokens with a specific API key secret.

verify_and_validate(bearer_token, key \\ __default_signer__(), context \\ %{})

Combines `verify/2` and `validate/2`

verify_and_validate!(bearer_token, key \\ __default_signer__(), context \\ %{})

Same as `verify_and_validate/2` but raises if error

# Functions

# 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()

    @spec get() :: {:ok, String.t()} | {:error, any()}

Gets a server token using the default API key from config. Tokens are cached per API key to avoid regenerating them unnecessarily.

# get(key, secret)

    @spec get(String.t(), String.t()) :: {:ok, String.t()} | {:error, any()}

Gets a server token for the specified API key and API key secret. Tokens are cached per API key to avoid regenerating them unnecessarily.

# signer()

    @spec signer() :: Joken.Signer.t()

Returns the signer used for server tokens.

# signer(secret)

    @spec signer(String.t()) :: Joken.Signer.t()

Returns the signer used for server tokens with a specific API key secret.

# 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