Skip to content

Instantly share code, notes, and snippets.

@enilsen16
Last active August 21, 2016 22:24
Show Gist options
  • Save enilsen16/c60caec6d021b72fbb016906c5c36e3c to your computer and use it in GitHub Desktop.
Save enilsen16/c60caec6d021b72fbb016906c5c36e3c to your computer and use it in GitHub Desktop.
Twilio Compadibility Tokens in elixir
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