diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index c818cca..e85d9c8 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -27,7 +27,14 @@ defmodule Ueberauth.Strategy.Google.OAuth do """ def client(opts \\ []) do config = Application.get_env(:ueberauth, __MODULE__, []) - opts = @defaults |> Keyword.merge(config) |> Keyword.merge(opts) |> resolve_values() + + opts = + @defaults + |> Keyword.merge(config) + |> Keyword.merge(opts) + |> resolve_values() + |> generate_secret() + json_library = Ueberauth.json_library() OAuth2.Client.new(opts) @@ -89,4 +96,14 @@ defmodule Ueberauth.Strategy.Google.OAuth do defp resolve_value({m, f, a}) when is_atom(m) and is_atom(f), do: apply(m, f, a) defp resolve_value(v), do: v + + defp generate_secret(opts) do + if is_tuple(opts[:client_secret]) do + {module, fun} = opts[:client_secret] + secret = apply(module, fun, [opts]) + Keyword.put(opts, :client_secret, secret) + else + opts + end + end end