简体   繁体   English

Dropnet API C#未经授权的用户异常

[英]dropnet api c# unauthorized user exception

I am using dropnet api to access dropbox using c#.i send my apikey and secret key,i get token in response.but when i try to get account info or delete a file it throws unauthorized use exceptions.can any one help me.my code is as follow. 我正在使用dropnet api通过c#访问Dropbox。我发送我的apikey和密钥,我得到令牌作为响应。但是当我尝试获取帐户信息或删除文件时,它会引发未经授权的使用异常。有人可以帮助我。我代码如下。

 DropNet.DropNetClient client = new DropNet.DropNetClient("xxxxxxxxx", "xxxxxxxxx");
            DropNet.Models.UserLogin login = client.GetToken();
            client.UserLogin = login;
            string st=client.BuildAuthorizeUrl(client.UserLogin,null);
            client.Delete("/Public/testsk");
            var accountInfo = client.AccountInfo();

Regards, 问候,

Shah Khalid. 莎·哈立德(Shah Khalid)。

Dropbox API uses standard http error codes, in your case, 401 usually means that user access token expired or revoked and it should recreated, Dropbox API使用标准的http错误代码,在您的情况下,401通常表示用户访问令牌已过期或已撤消,应该重新创建它,

All you need to do is re-authenticate end user dropbox account by doing next steps in this order: 您需要做的就是通过按以下顺序执行以下步骤来重新认证最终用户保管箱帐户:

  1. your application basic authentication: 您的应用程序基本身份验证:

      client = new DropNetClient(Settings.Default.DropboxApiKey, Settings.Default.DropboxApiSecret); client.GetToken(); 
  2. Let user login Dropbox with their account and approve your Dropbox app: 让用户使用其帐户登录Dropbox并批准您的Dropbox应用:

      string url = Client.BuildAuthorizeUrl(); 
  3. Retrieve and save authenticated user token: 检索并保存经过身份验证的用户令牌:

      UserLogin accessToken = Client.GetAccessToken(); Account.Token = accessToken.Token; Account.Secret = accessToken.Secret; Account.Status = AccountStatus.Active; 

last - save account data in your app - Account.Save() 最后-将帐户数据保存在您的应用中-Account.Save()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM