Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix client config precedence #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/ueberauth/strategy/twitter/oauth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ defmodule Ueberauth.Strategy.Twitter.OAuth do
config = Application.get_env(:ueberauth, __MODULE__)

@defaults
|> Keyword.merge(config)
|> Keyword.merge(opts)
|> Keyword.merge(config, &merge_present_values/3)
|> Enum.into(%{})
end

defp merge_present_values(_key, left, nil), do: left
defp merge_present_values(_key, _left, right), do: right

def get(url, access_token), do: get(url, [], access_token)
def get(url, params, {token, token_secret}) do
client()
Expand Down Expand Up @@ -93,7 +96,7 @@ defmodule Ueberauth.Strategy.Twitter.OAuth do
{:ok, {token, token_secret}}
end

defp decode_response({:ok, %{status_code: status_code, body: %{"errors" => [error | _]}}}) do
defp decode_response({:ok, %{body: %{"errors" => [error | _]}}}) do
{:error, %ApiError{message: error["message"], code: error["code"]}}
end

Expand Down