【发布时间】:2015-03-03 13:26:27
【问题描述】:
我的目标是在 C# 中通过 DropBoxRest API 获取文件
我想获取令牌时遇到以下错误
“System.AggregateException”类型的未处理异常发生在 mscorlib.dll
我做错了什么?
这是我的代码
var options = new Options
{
ClientId = "", //App key
ClientSecret = "", //App secret
RedirectUri = "https://www.dropbox.com/1/oauth2/authorize"
};
// Initialize a new Client (without an AccessToken)
var client = new Client(options);
// Get the OAuth Request Url
var authRequestUrl = await client.Core.OAuth2.AuthorizeAsync("");
// TODO: Navigate to authRequestUrl using the browser, and retrieve the Authorization Code from the response
var authCode = ""; Which code have to be here ???
// Exchange the Authorization Code with Access/Refresh tokens
var token = await client.Core.OAuth2.TokenAsync(authCode); in this line occured the following error
//An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll
// Get account info
var accountInfo = await client.Core.Accounts.AccountInfoAsync();
【问题讨论】:
-
在什么时候你在上面的代码中遇到了错误?
-
此时 var token = await client.Core.OAuth2.TokenAsync(authCode);
-
你是如何获得 authCode 的?
-
我不知道如何获得 authCode :) 我认为这是错误的原因
-
您的代码显示您出于某种原因在 Dropbox 服务器上发出请求。您应该阅读他们的 API 以了解如何获取正确的 authCode。
标签: c# .net web-services rest dropbox-api