DotNetOpenAuth OAuth2 for Basecamp API
Asked Answered
S

1

5

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

Schoolhouse answered 3/7, 2013 at 17:58 Comment(1)
hey Dominic: mate I need some help with basecamp authantication. I'm trying to get login using base camp as MVC project gives use Google facebook etc how can I get log in using my basecamp credentialsDoubleness
A
7

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.

Aba answered 5/7, 2013 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.