Joken

Summary

decode(pid, jwt, claims \\ %{})

Decodes the given JSON Web Token and gets the payload. Optionally checks against the given claims for validity

encode(pid, payload, claims \\ %{})

Encodes the given payload and optional claims into a JSON Web Token

start_link(otp_app)

Starts a Joken server by looking for the settings in the given config block or Starts a Joken server with the given configuration map

start_link(secret_key, json_module, algorithm \\ :HS256)

Starts a Joken server with the given parameters

Types

algorithm :: :HS256 | :HS384 | :HS512

status :: :ok | :error

payload :: %{} | Keyword.t

Functions

decode(pid, jwt, claims \\ %{})

Specs:

Decodes the given JSON Web Token and gets the payload. Optionally checks against the given claims for validity

Joken.decode(joken_pid, token, %{ aud: "self" })
encode(pid, payload, claims \\ %{})

Specs:

Encodes the given payload and optional claims into a JSON Web Token

Joken.encode(joken_pid, %{ name: "John Doe" }, %{ iss: "self"})
start_link(otp_app)

Specs:

  • start_link(%{}) :: {status, pid}
  • start_link(atom) :: {status, pid}

Starts a Joken server by looking for the settings in the given config block or Starts a Joken server with the given configuration map.

algorithm is optional and defaults to :HS256

config :my_otp_app, secret_key: "test", algorithm: :HS256, json_module: TestPoison

Joken.start_link(:my_otp_app)

#or

config = %{secret_key: "test", algorithm: :HS256, json_module: TestJsx}
Joken.start_link(config)
start_link(secret_key, json_module, algorithm \\ :HS256)

Specs:

Starts a Joken server with the given parameters

Joken.start_link("test", TestJsx, :HS256)