适用于Basecamp API的DotNetOpenAuth OAuth2 [英] DotNetOpenAuth OAuth2 for Basecamp API
本文介绍了适用于Basecamp API的DotNetOpenAuth OAuth2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很难让OAuth2与DotNetOpenAuth一起用于Basecamp API,这是我到目前为止所拥有的,这是一个ASP.NET MVC 4 Web应用程序.
I'm having some difficulties getting the OAuth2 working for the Basecamp API with DotNetOpenAuth, here's what I have so far, this is a ASP.NET MVC 4 web app.
public ActionResult Basecamp()
{
var server = new DotNetOpenAuth.OAuth2.AuthorizationServerDescription();
server.AuthorizationEndpoint = new Uri("https://launchpad.37signals.com/authorization/new");
server.TokenEndpoint = new Uri("https://launchpad.37signals.com/authorization/token");
var client = new DotNetOpenAuth.OAuth2.WebServerClient(
server, "my-basecamp-id", "my-basecamp-secret");
client.RequestUserAuthorization(returnTo: new Uri("http://localhost:55321/settings/basecampauth"));
Response.End();
return null;
}
[HttpPost]
public ActionResult BasecampAuth()
{
var server = new DotNetOpenAuth.OAuth2.AuthorizationServerDescription();
server.AuthorizationEndpoint = new Uri("https://launchpad.37signals.com/authorization/new");
server.TokenEndpoint = new Uri("https://launchpad.37signals.com/authorization/token");
var client = new DotNetOpenAuth.OAuth2.WebServerClient(
server, "my-basecamp-id", "my-basecamp-secret");
var state = client.ProcessUserAuthorization(Request);
Response.Write(state.AccessToken);
Response.End();
return null;
}
这是我从大本营得到的错误:
The is the error I get from Basecamp:
---
:error: "Unsupported type: nil. We support user_agent and web_server."
我尝试搜索并环顾四周,但没有发现太多有趣的地方.任何帮助/指针将不胜感激.
I've tried to search and look around, and could not found much interesting. Any help / pointer would be appreciated.
谢谢
推荐答案
更改此内容:
server.AuthorizationEndpoint = new Uri("https://launchpad.37signals.com/authorization/new");
对此:
server.AuthorizationEndpoint = new Uri("https://launchpad.37signals.com/authorization/new?type=web_server");
注意:我在uri的末尾添加了type=web_server
.
Note: i added type=web_server
to the end of the uri.
摘录自这些官方文档.
这篇关于适用于Basecamp API的DotNetOpenAuth OAuth2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文