0

I tried to using the new API sharpbox 1.2.

I tried this code:

if (Request.UrlReferrer.ToString() == string.Empty)           
{
  DropBoxConfiguration config = DropBoxConfiguration.GetStandardConfiguration();
  config.AuthorizationCallBack = new Uri("http://localhost:60003/Default.aspx");               
  DropBoxRequestToken token = DropBoxStorageProviderTools.GetDropBoxRequestToken(config, "customerkey", "customersecret");
  string authUrl = DropBoxStorageProviderTools.GetDropBoxAuthorizationUrl(config, token);     
  Response.Redirect(authUrl);
}             
else 
{ 
  ICloudStorageAccessToken token1 = DropBoxStorageProviderTools.LoginWithMobileAPI("username", "password", "customerkey", "customersecret");           
}

But I got an Exception like this:

"Attempted to perform an unauthorized operation"

I'm using Asp.NET & C#

Thanks a lot!

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135

1 Answers1

2

Sharpbox 1.2 eliminated the username/password pass. You must use the ICloudStorageAccessToken to get your token. There is a standalone exe in the download to turn your consumerkey and consumersecret into a token.

Public dropBoxStorage As CloudStorage
    dropBoxStorage = New CloudStorage()
    Dim dropBoxConfiguration As ICloudStorageConfiguration = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox)
    Dim accesstoken As ICloudStorageAccessToken = Nothing
    Dim tokenpath As String = serverpath 
    Dim fs As FileStream = File.Open(tokenpath, FileMode.Open, FileAccess.Read, FileShare.Read)
    accesstoken = dropBoxStorage.DeserializeSecurityToken(fs)
    dropBoxStorage.Open(dropBoxConfiguration, accesstoken)
Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161
jimmy6509
  • 33
  • 1
  • 8
  • I have downloaded that exe he is mentioning but it is not working to generate the token. I had to debug the code, generate on the fly `var accessToken = DropBoxStorageProviderTools.ExchangeDropBoxRequestTokenIntoAccessToken(config, ConsumerKey, ComsumerSecret, requestToken);` then generated a string `string accessTokenString = dropBoxStorage.SerializeSecurityTokenToBase64Ex(accessToken, typeof(ICloudStorageAccessToken), null);` – Junior Mayhé Nov 21 '12 at 17:40
  • Everything works but I can only download the file one time only with GetFileSystemObjectUrl. Even with full permissions, access token generated, list the folders and files, but it is pretty wierd Sharpbox hasn't an easy way to generate a user friendly public url link. When you visit the download link for a document, you will see `{"error": "Invalid or missing signature"}`. – Junior Mayhé Nov 21 '12 at 17:43