Skip to content

Instantly share code, notes, and snippets.

@enilsen16
Last active August 21, 2016 22:24
Show Gist options
  • Select an option

  • Save enilsen16/c60caec6d021b72fbb016906c5c36e3c to your computer and use it in GitHub Desktop.

Select an option

Save enilsen16/c60caec6d021b72fbb016906c5c36e3c to your computer and use it in GitHub Desktop.

Revisions

  1. enilsen16 revised this gist Aug 21, 2016. No changes.
  2. enilsen16 created this gist Aug 21, 2016.
    17 changes: 17 additions & 0 deletions twilio_token.ex
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    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