问题
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.
Thanks
回答1:
Change this:
server.AuthorizationEndpoint = new Uri("https://launchpad.37signals.com/authorization/new");
to this:
server.AuthorizationEndpoint = new Uri("https://launchpad.37signals.com/authorization/new?type=web_server");
Note: i added type=web_server
to the end of the uri.
Take from these official docs.
来源:https://stackoverflow.com/questions/17455074/dotnetopenauth-oauth2-for-basecamp-api