DotNetOpenAuth OAuth2 for Basecamp API

本文关键字:API Basecamp for OAuth2 DotNetOpenAuth | 更新日期: 2023-09-27 18:20:50

我在使用DotNetOpenAuth使OAuth2为Basecamp API工作时遇到了一些困难,这是迄今为止我所拥有的,这是一个ASP.NET MVC 4 web应用程序。

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;
}

这是我从Basecamp得到的错误:

--- 
:error: "Unsupported type: nil. We support user_agent and web_server."

我试着四处寻找,找不到什么有趣的东西。任何帮助/指示都将不胜感激。

感谢

DotNetOpenAuth OAuth2 for Basecamp API

更改此项:

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

请参阅这些官方文件。