Closed peburrows closed 6 years ago
@peburrows When developing locally, I notice that this line always fails: https://github.com/peburrows/goth/blob/df400832bd614cb14a606ba42c4d5b9f15394072/lib/goth/config.ex#L113
So, my custom config module is never actually run. I haven't been able to get my goth config working properly because of this. Any possible fix in mind?
Edit: In further investigating, I discovered that Code.ensure_loaded(mod)
(non-boolean response) returns {:error, :nofile}
. My config module does exist though.
Strange. What do your module and your config look like? If nothing jumps out as wrong in your module or the config, the simplest reproducible example would help me to debug this.
I am storing the credentials as base64 and then decoding them into the json format.
This is what my config looks like:
config :goth, config_module: MyApp.GothConfig
And this is what my config module looks like:
defmodule MyApp.GothConfig do
use Goth.Config
def init(config) do
credentials =
(Application.get_env(:my_app, :credentials) ||
System.get_env("GOOGLE_APPLICATION_CREDENTIALS"))
|> Base.decode64()
|> elem(1)
{:ok, Keyword.put(config, :json, credentials)}
end
end
Hrm, that all looks fine. What does your mix.exs
file look like, and are you able to reproduce this in a bare project with Goth as the only dependency?
Upon further investigation, I found that the issue was caused by my config file living in the config
directory, so it wasn't getting compiled. I fixed this and now Goth is able to find my module
Awesome, glad you were able to figure it out!
To use: