server_utils v0.1.5 ServerUtils.Jwt.JwtParser

JWT parser to get claim values.

Link to this section Summary

Functions

Gets a claim value using the claim key from a JWT. Optional this call can fail if error_if_blank is provided

Link to this section Functions

Link to this function get_claim(jwt, claim_key, opts \\ [error_if_blank: false])
get_claim(String.t(), String.t(), Keyword.t()) :: {atom(), String.t()}

Gets a claim value using the claim key from a JWT. Optional this call can fail if error_if_blank is provided.

Examples

iex> ServerUtils.Jwt.JwtParser.get_claim("example_jwt", "username")
{:ok, "luke"}

iex> ServerUtils.Jwt.JwtParser.get_claim("example_jwt", "username")
{:ok, ""}

iex> ServerUtils.Jwt.JwtParser.get_claim("example_jwt", "username", error_if_blank: true)
{:error, "Blank claim username"}