Current section
Files
Jump to
Current section
Files
lib/teac.ex
defmodule Teac do
@moduledoc """
Documentation for `Teac`.
"""
def new(opts) do
%Teac.Client{
token: Keyword.fetch!(opts, :token),
client_id: Keyword.get(opts, :client_id, client_id()),
req_options:
Keyword.get(opts, :req_options, Application.get_env(:teac, :api_req_options, []))
}
end
def api_uri, do: Application.get_env(:teac, :api_uri)
def auth_uri, do: Application.get_env(:teac, :auth_uri)
def client_id, do: Application.get_env(:teac, :client_id)
def client_secret, do: Application.get_env(:teac, :client_secret)
def redirect_uri, do: Application.get_env(:teac, :oauth_callback_uri)
def random_string do
:crypto.strong_rand_bytes(32)
|> Base.url_encode64()
|> String.replace(~r/[\+\/]/, "-")
|> String.replace(~r/=+$/, "")
end
end