Updated Tutorials

Jan 27, 2012 at 2:52 PM
Edited Jan 27, 2012 at 2:54 PM

I've downloaded the tutorials and updated the sample code correspondingly to reflect to new authorization procedures of v1.2 but get the following error when executing:


 storageToken = dropBoxStorage.Open(config, DropBoxStorageProviderTools.ExchangeDropBoxRequestTokenIntoAccessToken(config, "my key", "my Secret", requestToken));


 "UnauthorizedAccessException: Attempted to perform an unauthorized operation."

I've verified the "My Key" and "My secret" values assigned by Dropbox are valid. (It would be very useful to have a working code sample which reflected the latest version.)

Here is the complete code fragment from my test console app:

        static void Main(string[] args)
            // Creating the cloudstorage object
            CloudStorage dropBoxStorage = new CloudStorage();

            // get the config of dropbox
            DropBoxConfiguration config = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as DropBoxConfiguration;

            // set your own callback which will be called from DropBox after successful
            // authorization
            config.AuthorizationCallBack = new Uri("http://localhost:81");

            // create a request token
            DropBoxRequestToken requestToken = DropBoxStorageProviderTools.GetDropBoxRequestToken(config, "My Key", "My Secret");

            // call the authorization url via WebBrowser Plugin
            String AuthorizationUrl = DropBoxStorageProviderTools.GetDropBoxAuthorizationUrl(config, requestToken);

            // create the storageToken by exchanging the Request token to an access tokenaccess token
            var storageToken = dropBoxStorage.Open(config, DropBoxStorageProviderTools.ExchangeDropBoxRequestTokenIntoAccessToken(config, "My Key", "My Secret", requestToken));


            // do what ever you want to

            // get a specific directory in the cloud storage, e.g. /Public
            var publicFolder = dropBoxStorage.GetFolder("/Public");

            // enumerate all child (folder and files)
            foreach (var fof in publicFolder)
                // check if we have a directory
                Boolean bIsDirectory = fof is ICloudDirectoryEntry;

                // output the info
                Console.WriteLine("{0}: {1}", bIsDirectory ? "DIR" : "FIL", fof.Name );

            // upload a testfile from temp directory into public folder of DropBox
            String srcFile = Environment.ExpandEnvironmentVariables("%temp%\\test.dat");
            dropBoxStorage.UploadFile(srcFile, publicFolder);

            // download the testfile from DropBox
            dropBoxStorage.DownloadFile(publicFolder, "test.dat", Environment.ExpandEnvironmentVariables("%temp%"));

            // upload a testfile from temp directory into public folder of DropBox
            // with progress information
            dropBoxStorage.UploadFile(srcFile, publicFolder, UploadDownloadProgress);

            // download the testfile from DropBox with progress information
            dropBoxStorage.DownloadFile(publicFolder, "test.dat", Environment.ExpandEnvironmentVariables("%temp%"), UploadDownloadProgress);

            // close the connection

BTW, there doesn't seem to be an AccessToken property. Thanks in advance