1
Vote

System.UnauthorizedAccessException was unhandled by user code

description

protected void Page_Load(object sender, EventArgs e)
    {
        DropBoxConfiguration config = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as DropBoxConfiguration;
        config.AuthorizationCallBack = new Uri("http://localhost:61926/DBoxDemo.aspx");
        DropBoxRequestToken requestToken = DropBoxStorageProviderTools.GetDropBoxRequestToken(config,"<app key>", "<app secret>");
        Session["requestToken"] = requestToken;
        string AuthoriationUrl = DropBoxStorageProviderTools.GetDropBoxAuthorizationUrl(config, requestToken);

        if (!string.IsNullOrEmpty(Request.QueryString["oauth_token"]))
        {


            __ICloudStorageAccessToken accessToken = DropBoxStorageProviderTools.ExchangeDropBoxRequestTokenIntoAccessToken(config, "<app key>", "<app secret>", requestToken); 
__
            CloudStorage dropBoxStorage = new CloudStorage();

            var storageToken = dropBoxStorage.Open(config, accessToken);
            var publicFolder = dropBoxStorage.GetFolder("/");

            // upload a testfile from temp directory into public folder of DropBox
            String srcFile = Environment.ExpandEnvironmentVariables(@"C:\Test\MyTestFile.txt");
            dropBoxStorage.UploadFile(srcFile, publicFolder);
        }
        else
        {

            Response.Redirect(AuthoriationUrl);
        }
    }
This code gives Error when i declare ICloudStorageAccessToken accessToken= ......................;

file attachments

comments

decosmilan wrote Jan 28, 2015 at 5:30 AM

Please help ASAP

wrote Jan 28, 2015 at 5:36 AM