peburrows / goth

Elixir package for Oauth authentication via Google Cloud APIs
http://hexdocs.pm/goth
MIT License
284 stars 108 forks source link

Config from ENV var in README does not behave as described #59

Closed yuchunc closed 5 years ago

yuchunc commented 5 years ago

Referring to this section: https://github.com/peburrows/goth/blob/master/README.md#L26-L29

In the README it says to pass in the path from system ENV, but looking function Goth.Config.load_and_init/1, it is triggering Goth.Config.from_json/1 function.

https://github.com/peburrows/goth/blob/master/lib/goth/config.ex#L121-L127

It will produce not valid json format from Jason.

I think it is missing a step. If :json is a path, it should load the json file before decoding with Jason. Or, it should be limited to just json string when using this config option?

peburrows commented 5 years ago

Maybe it's not clear, but if you are passing a {:system, var} tuple in the :json config, that ENV var needs to be the json itself, not the path to a file. Anything passed in Goth's :json config needs to actually be json.

For the most part, Goth expects the json directly, not a path to a file that includes the json.

One exception to that (and this is to support the App Engine case), is if you set the GOOGLE_APPLICATION_CREDENTIALS env variable; setting that variable to the path of your json credentials file should work without any other configuration.

yuchunc commented 5 years ago

@peburrows đź‘Ť

Would it be clearer if the config option accepts the json path instead of the raw json?

peburrows commented 5 years ago

No, I don’t believe so; I think the json itself makes the most sense.