Created
August 27, 2015 07:38
-
-
Save olivermt/8a8a3094f5e16338ba8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iex(15)> {:ok,payload} = Poison.encode %{"user_id" => 1, "roles" => ["admin", "user"], "metadata" => %{"foo" => "bar"}} | |
{:ok, | |
"{\"user_id\":1,\"roles\":[\"admin\",\"user\"],\"metadata\":{\"foo\":\"bar\"}}"} | |
iex(16)> token = Phoenix.Token.sign(Core.Endpoint, "bar", payload) | |
"g3QAAAACZAAEZGF0YW0AAAA/eyJ1c2VyX2lkIjoxLCJyb2xlcyI6WyJhZG1pbiIsInVzZXIiXSwibWV0YWRhdGEiOnsiZm9vIjoiYmFyIn19ZAAGc2lnbmVkbgYAaGwXbk8B--7TCEz5KiWYV4F8lPc5dbJjbpsAE=" | |
iex(17)> {:ok,decoded} = Phoenix.Token.verify(Core.Endpoint, "bar", token) | |
{:ok, | |
"{\"user_id\":1,\"roles\":[\"admin\",\"user\"],\"metadata\":{\"foo\":\"bar\"}}"} | |
iex(18)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment