I found a small bug with the changes i made earlier. For example, in this part:
```elixir opts = Keyword.validate!(opts, key: Config.get_key(), client_id: Config.client_id(), redirect_uri: Config.redirect_uri(), extra_redirect_uris: Config.extra_redirect_uris(), scopes: Config.scopes() )
Elixir evaluates every function call before passing it to the keyword list in the second argument, so Config.get_key() always gets called. The crash occurs in that function:
```elixir
def get_key() do
private_key =
Application.fetch_env!(:atex, Atex.OAuth)[:private_key]
|> Base.decode64!()
```
so, if :private_key isn't defined, it tries to call Base.decode64!(nil), causing it to throw an error.
The solution i propose is using Keyword.validate! without any default values, then using Keyword.get_lazy() to evaluate a default function only in case the opt wasn't passed:
```elixir
opts =
Keyword.validate!(
opts,
[:key, :client_id, :redirect_uri, :extra_redirect_uris, :scopes]
)
key = Keyword.get_lazy(opts, :key, &Config.get_key/0)
client_id = Keyword.get_lazy(opts, :client_id, &Config.client_id/0)
redirect_uri = Keyword.get_lazy(opts, :redirect_uri, &Config.redirect_uri/0)
```
This should prevent the config functions from being called when not necessary.
When i tested locally last time i forgot to try without the runtime config, so i didn't catch the bug. Sorry for the inconvenience