C# Sharpbox API远程服务器返回错误:(401)未经授权

C# Sharpbox API远程服务器返回错误:(401)未经授权,c#,oauth,dropbox,dropbox-api,sharpbox,C#,Oauth,Dropbox,Dropbox Api,Sharpbox,我正在使用sharpBox API连接到DropBox。它正确地上传了文件,但是当它试图下载文件时,它给出了错误 远程服务器返回错误:401未经授权 我的代码如下 using AppLimit.CloudComputing.SharpBox; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Ta

我正在使用sharpBox API连接到DropBox。它正确地上传了文件,但是当它试图下载文件时,它给出了错误

远程服务器返回错误:401未经授权

我的代码如下

using AppLimit.CloudComputing.SharpBox;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DropBox
{
    public class Program
    {
        static void UploadDownloadProgress(Object sender, FileDataTransferEventArgs e)
        {
            // print a dot
            Console.WriteLine("Downloading");
            Console.WriteLine(".");
            // it's ok to go forward
            e.Cancel = false;
        }

        static void UploadProgress(Object sender, FileDataTransferEventArgs e)
        {
            // print a dot
            Console.Write(".");
            // it's ok to go forward
            e.Cancel = false;
        }


        public static void DownloadFolder(CloudStorage dropBoxStorage, ICloudDirectoryEntry remoteDir, string targetDir, string sourceDir)
        {
            foreach (ICloudFileSystemEntry fsentry in remoteDir)
            {
                var filepath = Path.Combine(targetDir, fsentry.Name);

                if (fsentry is ICloudDirectoryEntry)
                {
                    Console.WriteLine("Created: {0}", filepath);
                    Directory.CreateDirectory(filepath);
                    DownloadFolder(dropBoxStorage, fsentry as ICloudDirectoryEntry, filepath, sourceDir);
                }
                else
                {
                    dropBoxStorage.DownloadFile(remoteDir, fsentry.Name, targetDir, UploadDownloadProgress);

                }
            }
        }

        public static void UploadFile(CloudStorage dropBoxStorage, ICloudDirectoryEntry remoteDir, string targetDir)
        {
            dropBoxStorage.UploadFile(targetDir, remoteDir, UploadProgress);
        }

        static void Main(string[] args)
        {
            CloudStorage dropBoxStorage = new CloudStorage();

            var dropBixConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox);

            ICloudStorageAccessToken accessToken = null;

            using (FileStream fs = File.Open(@"token.txt", FileMode.Open, FileAccess.Read, FileShare.None))
            {
                accessToken = dropBoxStorage.DeserializeSecurityToken(fs);
            }

            var storageToken = dropBoxStorage.Open(dropBixConfig, accessToken);

            //do stuff
            var root = dropBoxStorage.GetRoot();

            var publicFolder = dropBoxStorage.GetFolder("/");

            foreach (var folder in publicFolder)
            {
                Boolean bIsDirectory = folder is ICloudDirectoryEntry;

                Console.WriteLine("{0}: {1}", bIsDirectory ? "DIR" : "FIL", folder.Name);
            }

            string remoteDirName = @"/Public";
            string targetDir = "M://Drop";
            var remoteDir = dropBoxStorage.GetFolder(remoteDirName);


            DownloadFolder(dropBoxStorage, remoteDir, targetDir, remoteDirName);

            dropBoxStorage.Close();
        }

        public delegate void FileOperationProgressChanged(object sender, FileDataTransferEventArgs e);
    }
}

API在响应中应该有更具体的错误消息。你能打印出来吗?这似乎是运行在.NET 4.5上的SharpBox的一个错误。可能重复的