Hey Folks,
I’ve been spending days trying to get the Dropbox REST API to work. I got the Twitter sample code to work and I’ve been trying to modify that code to work with Dropbox.
I swapped out the Twitter REST URLs with the appropriate Dropbox REST URLs, but I run into a problem when I attempt to request token:
https://api.dropbox.com/1/oauth/request_token
Here is the error message I get when attempting the above request:
{“error”: “OAuthError in API v1+. Request mis-signed: Invalid or Missing Signature”}
Dropbox says that they require UTF-8 encoding and unicode normalization (NFC), but Twitter also says they require UTF-8 encoding and the sample code works fine with Twitter.
Just in case, I found a UTF-8 encoding library for Lua in the code exchange, but I’m not quite sure at what point in the request process the encoding should occur- do I encode the app key and app secret prior to doing anything else?
I have also read that it is recommended to use PLAINTEXT for Dropbox instead of HMAC-SHA1 as an oauth signature method (they say if you use https, it’s PLAINTEXT is fine). I tried to use PLAINTEXT, but for some reason I get an error message (from Dropbox) that I must use HTTPS if I want to use PLAINTEXT, but my code looks like it is using https. The Twitter code example uses http.request, but from my reading of the Corona API, it looks like that does not support HTTPS. It’s weird, though, because the Twitter example uses https URLs and they seem to work fine with http.request. Even so, I’m thinking I might do better using network.request, but I’m not entirely sure how to convert from http.request to network.request in the Twitter sample code. Here’s the code snippet for your convenience:
function rawPostRequest(url, rawdata)
local r,c,h
local response = {}
r,c,h = http.request
{
url = url,
method = "POST",
headers =
{
["Content-Type"] = "application/x-www-form-urlencoded",
["Content-Length"] = string.len(rawdata)
},
source = ltn12.source.string(rawdata),
sink = ltn12.sink.table(response)
}
return table.concat(response,"")
end
If anyone has had any luck getting the Dropbox REST API to work, I would so love to hear about it. Or any opinions on my ideas above. Thanks. [import]uid: 104085 topic_id: 29909 reply_id: 329909[/import]