goth icon indicating copy to clipboard operation
goth copied to clipboard

Cannot use Base64 Encoded Env Var for generating Signed URLs

Open JohnnyCurran opened this issue 8 months ago • 0 comments

Hi,

we base64 encode our GOOGLE_APPLICATION_CREDENTIALS_JSON before passing it to Goth.

Our named Goth process is configured correctly, but when attempting to use url/4:

url({file_name, upload}, :original, signed: true)

the process crashes because decode_json reads the env var directly and attempts to Jason.decode! it, which fails because the env var is b46 encoded.

Patching the lib with:

  defp decode_json(json) do
    json
    # adding this line lets it work
    |> Base.decode64!()
    |> Jason.decode!()
    |> set_token_source
  end

allows it to work. Is there any way we can configure Goth.Config to either read the configured dependency config at runtime or otherwise tell it that the env var is encoded?

JohnnyCurran avatar Jun 26 '24 14:06 JohnnyCurran