dimanche 22 octobre 2017

Can anyone suggest how to generate valid oauth_signature?

Please, help me to understand how to generate a valid oauth_signiture. I mean I can't understand the process. I must encode Shared secret and Access Secret using base64() and then URLencode()? Or encode Signature Base String? Or both?

I tried to generate the oauth_signiture by oauth_signature() function in 'httr' package but the response was the same. Also tried:

sha1_hash(key = "",string = secret,method = "HMAC-SHA1")

 getForm("http://ift.tt/KcDLU7",
    oauth_consumer_key=conskey,
    method="GET",
    oauth_nonce="8AQUCifnQ7",
    oauth_signature_method="HMAC-SHA1",
    oauth_signature="ft8HlTJ9osJ8COakfcgPVXBIBJQ=",
    oauth_timestamp=1508706399,
    oauth_version="1.0", 
    oauth_callback="http://127.0.0.1:1410",
    .opts = list(verbose = TRUE))

Here is the response.

 HTTP/1.1 200 OK
< Date: Sun, 22 Oct 2017 21:07:27 GMT
< Content-Type: text/xml; charset=utf-8
< Content-Length: 377
< Connection: keep-alive
< Cache-Control: private
< [1]
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
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<error 
 xmlns=\"http://ift.tt/2l8JrWu\" 
 xmlns:xsi=\"http://ift.tt/ra1lAU\" 
 xsi:schemaLocation=\"http://ift.tt/2l8JrWu 
 http://ift.tt/2zv7elB\">
 \r\n\t<code>8</code>\r\n\t<message>Invalid signature: oauth_signature 
 'ft8HlTJ9osJ8COakfcgPVXBIBJQ='</message>\r\n</error>\r\n"
 attr(,"Content-Type")
              charset 
"text/xml"    "utf-8" 

P.S. I read in FatSecret website that i must use the HMAC-SHA1 signature algorithm as defined by the to sign the request where text is the Signature Base String and key is the concatenated values of the Consumer Secret and Access Secret separated by an '&' character (show '&' even if Access Secret is empty as some methods do not require an Access Token). But still can't understand can someone show an example?




Aucun commentaire:

Enregistrer un commentaire