错误的oauth_signature

时间:2017-12-20 23:16:42

标签: r oauth data-retrieval

拜托,你能帮我弄清楚签名有什么问题吗?我真的,无法理解这是什么问题。我一直在寻找答案超过一个月。如果你给我一个类似 工作 的例子 请求或帮助我理解这个问题我会非常感激!

library(RCurl)
library(httr)
library(rvest)

cons_key<-"ae1dd19212a84c4299f4b157462d32d7"
shared_secret<-"c0bc9938ea754f4ba6e926865b347fae"

encoded_url<-URLencode("http://platform.fatsecret.com/rest/server.api",reserved = T,repeated = T)
encoded_string<-URLencode("method=GET&oauth_consumer_key=cons_key&oauth_nonce=asdas4&oauth_signature_method=HMAC-SHA1&oauth_timestamp=15138110238&oauth_version=1.0",reserved = T,repeated = T)
text_string<-paste0("GET&",encoded_url,"&",encoded_string)

signature_oauth<-sha1_hash(key = "ae1dd19212a84c4299f4b157462d32d7&",string = text_string)

getForm("http://platform.fatsecret.com/rest/server.api",
    method="GET",
    oauth_consumer_key=cons_key,
    oauth_signature=signature_oauth,
    oauth_signature_method="HMAC-SHA1",
    oauth_timestamp="1513811023",
      oauth_nonce="asdas4",
    oauth_version="1.0",.opts = list(verbose = TRUE))

答案是:

 Trying 34.225.169.9...
 * Connected to platform.fatsecret.com (34.225.169.9) port 80 (#0)
  > GET /rest/server.api method=GET&oauth_consumer_key=ae1dd19212a84c4299f4b157462d32d7&oauth_signature=rB2IYo5tZ%2BAUIsk%2BjlP0ahtn%2Bhk%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1513811023&oauth_nonce=asdas4&oauth_version=1.0 HTTP/1.1
Host: platform.fatsecret.com
Accept: */*

 < HTTP/1.1 200 OK
 < Date: Wed, 20 Dec 2017 23:05:44 GMT
 < Content-Type: text/xml; charset=utf-8
 < Content-Length: 377
 < Connection: keep-alive
 < Cache-Control: private
 < Server: Microsoft-IIS/8.5
 < X-AspNet-Version: 4.0.30319
 < X-Powered-By: ASP.NET
   < 
  * Connection #0 to host platform.fatsecret.com left intact
  [1] "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<error 
 xmlns=\"http://platform.fatsecret.com/api/1.0/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://platform.fatsecret.com/api/1.0/ http://platform.fatsecret.com/api/1.0/fatsecret.xsd\">\r\n\t<code>8</code>\r\n\t<message>Invalid signature: oauth_signature 'rB2IYo5tZ+AUIsk+jlP0ahtn+hk='</message>\r\n</error>\r\n"
attr(,"Content-Type")
          charset 
"text/xml"    "utf-8" 

0 个答案:

没有答案