Last active
August 21, 2016 22:24
-
-
Save enilsen16/c60caec6d021b72fbb016906c5c36e3c to your computer and use it in GitHub Desktop.
Twilio Compadibility Tokens in elixir
This file contains hidden or 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
defmodule TwilioToken do | |
import Joken | |
@app Application.get_env(:speaker, :twilio_app) | |
@sid Application.get_env(:ex_twilio, :account_sid) | |
@token Application.get_env(:ex_twilio, :auth_token) | |
def generate do | |
%{scope: "scope:client:outgoing?appSid=#{@app}"} | |
|> token | |
|> with_iss(@sid) | |
|> with_signer(hs256(@token)) | |
|> with_exp | |
|> sign | |
|> get_compact | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment