【问题标题】:Oauth echo using elixir HTTPotion使用 elixir HTTPotion 的 Oauth 回显
【发布时间】:2016-07-14 19:20:36
【问题描述】:

我正在尝试在我的 phoenix 框架/elixir 后端验证 twitter 数字 api...当我使用 curl 时它成功了,但我真的不知道如何使用 HTTPotion 生成它...我尝试了不同的组合但总是返回"215", "错误的验证数据。"

这是我使用 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

到目前为止,这是我尝试使用 HTTPotion 做的,但仍然没有 运气

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 httprequest elixir phoenix-framework twitter-digits


    【解决方案1】:

    curl 命令只创建 1 个 Authorized 标头,而不是像 HTTPotion 代码那样的多个标头。

    这应该可行:

    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"|]])
    

    【讨论】:

    • 感谢@Dogbert 的快速回复我尝试了您的代码,但得到了这个响应:code ** (FunctionClauseError) HTTPotion.process_arguments/3 (httpotion) 中的匿名 fn/1 中没有函数子句匹配) lib/httpotion.ex:356: HTTPotion.process_arguments/3 (elixir) 中的匿名 fn("Authorization") lib/enum.ex:1088: Enum."-map/2-lists^map/1-0-" /2 (httpotion) 库/httpotion.ex:356: HTTPotion.process_arguments/3 (httpotion) 库/httpotion.ex:356: HTTPotion.request/3 code
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-13
    • 1970-01-01
    • 2023-03-27
    • 2015-11-21
    • 1970-01-01
    相关资源
    最近更新 更多