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
Functions
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" })
Specs:
Encodes the given payload and optional claims into a JSON Web Token
Joken.encode(joken_pid, %{ name: "John Doe" }, %{ iss: "self"})
Specs:
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)
Specs:
Starts a Joken server with the given parameters
Joken.start_link("test", TestJsx, :HS256)