-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to native Elixir dependency for OAuth (#14)
* Switch to OAuther from erlang-oauth * Clean up warnings * Cleanup per PR review.
- Loading branch information
Showing
5 changed files
with
78 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
defmodule Ueberauth.Strategy.Twitter.OAuth.Internal do | ||
@moduledoc """ | ||
A layer to handle OAuth signing, etc. | ||
""" | ||
|
||
def get(url, extraparams, {consumer_key, consumer_secret, _}, token \\ "", token_secret \\ "") do | ||
creds = OAuther.credentials( | ||
consumer_key: consumer_key, | ||
consumer_secret: consumer_secret, | ||
token: token, | ||
token_secret: token_secret | ||
) | ||
{header, params} = | ||
"get" | ||
|> OAuther.sign(url, extraparams, creds) | ||
|> OAuther.header | ||
|
||
HTTPoison.get(url, [header], params: params) | ||
end | ||
|
||
def params_decode(resp) do | ||
resp | ||
|> String.split("&", trim: true) | ||
|> Enum.map(&String.split(&1, "=")) | ||
|> Enum.map(&List.to_tuple/1) | ||
|> Enum.into(%{}) | ||
# |> Enum.reduce(%{}, fn({name, val}, acc) -> Map.put_new(acc, name, val) end) | ||
end | ||
|
||
def token(params) do | ||
params["oauth_token"] | ||
end | ||
|
||
def token_secret(params) do | ||
params["oauth_token_secret"] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters