Packages
goth
0.1.1
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.1
1.3.0
1.3.0-rc.5
1.3.0-rc.4
1.3.0-rc.3
1.3.0-rc.2
1.3.0-rc.1
1.3.0-rc.0
1.2.0
1.1.0
1.0.1
1.0.1-beta
1.0.0
0.11.1
0.11.0
0.10.0
0.9.0
0.8.2
0.8.1
0.8.0
0.7.2
0.7.1
0.7.0
0.6.0
0.5.1
0.5.0
0.4.0
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.3
0.0.2
0.0.1
A simple library to generate and retrieve Oauth2 tokens for use with Google Cloud Service accounts.
Current section
Files
Jump to
Current section
Files
lib/goth/config.ex
defmodule Goth.Config do
use GenServer
def start_link do
GenServer.start_link(__MODULE__, :ok, [name: __MODULE__])
end
def init(:ok) do
case Application.get_env(:goth, :json) do
nil -> {:ok, Application.get_env(:goth, :config, %{})}
json -> {:ok, Poison.decode!(json)}
end
end
def set(key, value) when is_atom(key), do: key |> to_string |> set(value)
def set(key, value) do
GenServer.call(__MODULE__, {:set, key, value})
end
def get(key) when is_atom(key), do: key |> to_string |> get
def get(key) do
GenServer.call(__MODULE__, {:get, key})
end
def handle_call({:set, key, value}, _from, keys) do
{:reply, :ok, Map.put(keys, key, value)}
end
def handle_call({:get, key}, _from, keys) do
{:reply, Map.fetch(keys, key), keys}
end
end