使用 elixir HTTPotion 的 Oauth echo

Oauth echo using elixir HTTPotion

我正在尝试在我的 phoenix framework/elixir 后端验证推特数字 api...当我使用 curl 时它成功了,但我真的不知道如何使用 HTTPotion 生成它.. . 我尝试了不同的组合,但总是 returns "215", "Bad Authentication data."

Here is my code when using curl

curl --get 'https://api.digits.com/1.1/sdk/account.json' --header 'Authorization: OAuth  oauth_signature="my-oauth-signature",oauth_nonce="my-oauty-nonce",oauth_timestamp="my-oauth-timestamp",oauth_consumer_key="my-oauth-consumer-key",oauth_token="my-oauth-token",oauth_version="1.0",oauth_signature_method="HMAC-SHA1"' -v

and this is so far what i tried to do using HTTPotion but still no luck

HTTPotion.get "https://api.digits.com/1.1/sdk/account.json", [headers: ["Authorization": "OAuth", "oauth_consumer_key": "my-oauth-consumer-key", "oauth_nonce": "my-oauth-nonce", "oauth_signature": "my-oauth-signature", "oauth_signature_method": "HMAC-SHA1", "oauth_timestamp": "my-oauth-timestamp", "oauth_token": "my-oauth-token", "oauth_version": "1.0"]] 

我搜索了几天,但没有找到任何东西...请有人帮助我..

curl 命令仅创建 1 个 Authorized header,而不是像 HTTPotion 代码那样创建多个 header。

这应该有效:

HTTPotion.get("https://api.digits.com/1.1/sdk/account.json",
              [headers: ["Authorization": ~s|OAuth  oauth_signature="my-oauth-signature",oauth_nonce="my-oauty-nonce",oauth_timestamp="my-oauth-timestamp",oauth_consumer_key="my-oauth-consumer-key",oauth_token="my-oauth-token",oauth_version="1.0",oauth_signature_method="HMAC-SHA1"|]])