Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
we are accessing having a problem in URL we have a file named xyx (1).jpg while passing this to server we are getting response as Unauthorized Access. May I Know how to pass this request to Server?
Here am using DropBox API for Winrt C#.
Yes I have trouble in thumbnails.
Can you share your latest code for retrieving thumbnails?
Avatar
file = await tempCatcheFolder.CreateFileAsync(fileName, CreationCollisionOption.OpenIfExists);
DropboxApi api = new DropboxApi(DropBoxAccessToken, DropBoxAccessTokenSecret);
string url = DriveUtilities.GenerateSignature(new Uri(string.Format(AppConstants.DropBoxGetThumbnail, item.serverFileId), UriKind.RelativeOrAbsolute),
"GET", DropBoxAccessToken, DropBoxAccessTokenSecret);
Stream fileStream = await FileHelper.getFileInputStream(url);
if (fileStream != null)
{
try
{
if (fileStream.Length > 0)
await FileSaveToStorage(fileStream, file);
handler(fileStream);
}
catch (Exception ex)
{
}
}
else
{
string path = WebUtility.UrlEncode(item.serverFileId);
url = DriveUtilities.GenerateSignature(new Uri(string.Format(AppConstants.DropBoxGetThumbnail, path), UriKind.RelativeOrAbsolute),
"GET", DropBoxAccessToken, DropBoxAccessTokenSecret);
fileStream = await FileHelper.getFileInputStream(url);
if (fileStream != null)
{
try
{
if (fileStream.Length > 0)
await FileSaveToStorage(fileStream, file);
handler(fileStream);
}
catch (Exception ex)
{
}
}
It looks like this code tries two different calls, one in which the file path is manually URL encoded and one in which it isn't. Why is that?
Maybe you can print out the value of "url" right before you make the call and share that, but please remember to replace the OAuth signature with Xs so you don't share your credentials.
in case of If block
https://api-content.dropbox.com/1/thumbnails/auto/images (87).jpeg?oauth_consumer_key=xs&oauth_token=xs&oauth_nonce=1015776&oauth_timestamp=1427259241&oauth_signature_method=PLAINTEXT&oauth_version=1&oauth_signature=xs
in case of else block.
https://api-content.dropbox.com/1/thumbnails/auto%2Fimages+(87).jpeg?oauth_consumer_key=xs&oauth_token=xs&oauth_nonce=724397&oauth_timestamp=1427259387&oauth_signature_method=PLAINTEXT&oauth_version=1&oauth_signature=xs
Everything looks roughly right (in the first URL), so I would assume that one of the parameters is wrong (oauth_consumer_key
, oauth_token
, or oauth_signature
).
Compare those values to the URL you use for /media
(the one that's working) to make sure everything's the same.
Okay let me see.
There is no difference between oauthconsumerkey, oauthtoken, or oauthsignature everything is same for both urls.
I'm not sure what's going wrong in your code, so I thought I'd instead provide some working code I wrote for you. The method below returns the full URI to download a thumbnail from Dropbox.
Note that I'm not using OAuthBase.GenerateSignature
. That method returns a URL-encoded version of the signature, which I found hard to work with. Because we're using PLAINTEXT signing, it's very easy to construct the signature yourself. It's just the app secret, then an ampersand (&), and then the token secret.
static Uri GetThumbnailUri(string path, string appKey, string appSecret, string token, string tokenSecret) {
var oauthBase = new OAuth.OAuthBase();
var ub = new UriBuilder(@"https://api-content.dropbox.com/1/thumbnails/auto/" + path.TrimStart('/'));
// get an empty HttpValueCollection
var parameters = HttpUtility.ParseQueryString(string.Empty);
// add all the OAuth parameters
parameters["oauth_consumer_key"] = appKey;
parameters["oauth_token"] = token;
parameters["oauth_nonce"] = oauthBase.GenerateNonce();
parameters["oauth_timestamp"] = oauthBase.GenerateTimeStamp();
parameters["oauth_version"] = "1.0";
parameters["oauth_signature_method"] = "PLAINTEXT";
parameters["oauth_signature"] = appSecret + "&" + tokenSecret;
// set the query string for the URL
ub.Query = parameters.ToString();
return ub.Uri;
}
Thank you for your Response.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!