【发布时间】:2017-12-16 10:11:58
【问题描述】:
我目前正在尝试使用 Box SDK for .NET 为 MVC Web 应用程序构建登录。 不过,我终其一生都无法绕开 Oauth 登录过程。我觉得我已经接近了,但实际的 POST 操作让我感到困惑。
这是我试图遵循的过程: https://developers.box.com/oauth/ 我被困在“第一条腿”部分。
我传递我的 uri 和数据属性以按预期发布
var data = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("response_type", "code"),
new KeyValuePair<string, string>("client_id", client_id),
new KeyValuePair<string, string>("box_login", account_email)
};
HttpResponseMessage values = await Post("https://app.box.com/api/oauth2/authorize", data);
使用自定义 Post() 方法包装器:
public static async Task<HttpResponseMessage> Post(string uri, List<KeyValuePair<string, string>> pairs)
{
using (HttpClient client = new HttpClient())
{
var content = new FormUrlEncodedContent(pairs);
var response = await client.PostAsync(uri, content);
return response;
}
}
但是“值”内容与 Box 授权页面的 html 一起返回。假设我应该重定向到这个页面......我真的不知道这样做的最佳方法(然后返回)。
我觉得这一切可能归结为我对 POST 工作原理的误解。我错过了什么明显而简单的事情?
【问题讨论】:
标签: c# asp.net-mvc-4 oauth sdk box