cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

URL Unauthorized access error while accessing files from dropbox?

URL Unauthorized access error while accessing files from dropbox?

sobharaj m.
New member | Level 1

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#.

39 Replies 39

sobharaj m.
New member | Level 1

For Thumbnails

string url = DriveUtilities.GenerateSignature(
    new Uri(string.Format(AppConstants.DropBox_GetThumbnail, item.serverFileId), UriKind.RelativeOrAbsolute),
            "GET", drive.AccessToken, drive.RefreshToken);
Stream fileStream = await FileHelper.getFileInputStream(url);

if (fileStream != null)
{
    try
    {
        if (fileStream.Length > 0)
            await FileSaveToStorage(fileStream, file);
        handler(fileStream);
    }
    catch (Exception ex)
    {
    }
}

for full image we are using this code (working)

WebProvider objWebProvider = new WebProvider();
string size = "?size=" + await CommonFunctions.GetThumbnailSize(DriveType.DROPBOX);
var uri = DriveUtilities.GenerateThumbviewSignature(
    new Uri(string.Format(AppConstants.DropBox_GetThumbnail, path) + size, UriKind.RelativeOrAbsolute),
            "GET", DropBox_AccessToken, DropBox_AccessTokenSecret);
url = uri.ToString();

Steve M.
Dropbox Staff

I'm confused.

What's the difference between DriveUtilities.GenerateSignature and DriveUtilities.GenerateThumbviewSignature?

And why does one piece of code use item.serverFileId and the other path? (Is the "serverFileId" the path?)

And both snippets seem to use AppConstants.DropBox_GetThumbnail as the base URL, but I thought the second code snippet was supposed to be retrieving the full image (not a thumbnail).

sobharaj m.
New member | Level 1

Yes the second one is for getting full image. No need to confuse we used same method but only the name is different here path and item.serverField means name of that particular image. In both cases everything is same except the URL. The url is different for full view image and thumbnail.

Steve M.
Dropbox Staff

What's the value of AppConstants.DropBox_GetThumbnail?

sobharaj m.
New member | Level 1

DropBox_GetThumbnail = "https://api-content.dropbox.com/1/thumbnails/auto{0}"; {0} means we are appending image information here.

Steve M.
Dropbox Staff

Both code snippets use AppConstants.DropBox_GetThumbnail. So they both seem to be requesting thumbnails.

Steve M.
Dropbox Staff

Another issue I noticed: the first code snippet passes drive.AccessToken and drive.RefreshToken. Dropbox doesn't use a refresh token. Presumably you should be passing the access token secret as the second parameter.

sobharaj m.
New member | Level 1

Okay. Thanks for your support.

sobharaj m.
New member | Level 1

Hi Actually I sent you wrong code regarding success case.

Here it am sending you again.

WebProvider objWebProvider = new WebProvider();
//   path = WebUtility.UrlEncode(path);
var uri = DriveUtilities.GenerateSignature(
    new Uri(string.Format(AppConstants.DropBox_GetMediaItem, path), UriKind.RelativeOrAbsolute),
    "GET", DropBox_AccessToken, DropBox_AccessTokenSecret);

uri = await objWebProvider.GETRequest(uri).ConfigureAwait(false);

if (!string.IsNullOrEmpty(uri) && !uri.Equals(AppConstants.Unauthorized))
{
    DropBoxThumbnail result = JsonConvert.DeserializeObject<DropBoxThumbnail>(uri);

    if (result != null)
        url = result.url;
}

Steve M.
Dropbox Staff

Are you still having trouble, or is your code working now?

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    sobharaj m. New member | Level 1
  • User avatar
    Steve M. Dropbox Staff
What do Dropbox user levels mean?