Archived Support Site

This support site is archived. You can view the old support discussions but you cannot post new discussions.

Basic OAuth token endpoint yielding 404

smonn's Avatar

smonn

29 Feb, 2016 09:48 AM

I have a very basic OAuth setup like this in my OWIN-based Startup.cs:

app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions
{
  TokenEndpointPath = new PathString("/token"),
  AccessTokenExpireTimeSpan = TimeSpan.FromHours(8),
  Provider = new SimpleAuthorizationServerProvider(),
});
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

The Web API controller routes work just fine, it's just the OAuth routes that seem to not be working (getting 404 status). Am I missing something? Let me know if I more details are needed. Obviously this all work in my local environment.

  1. Support Staff 1 Posted by rune on 29 Feb, 2016 08:07 PM

    rune's Avatar

    Hi,

    I'm not sure what the issue might be here -- can you let me know the name of the application so I can take a closer look? Also, how can the issue be reproduced (i.e. does the application return the 404 when POSTing og GETing the /tokens endpoint)?

    Best,
    Rune

  2. 2 Posted by smonn on 01 Mar, 2016 08:03 AM

    smonn's Avatar

    The name of the app is ebb92bdae. It returns 404 for both POST and GET on that endpoint.

    The expected behavior is that if you send a POST request with the following headers and body:

    Accept: application/json
    Content-Type: application/x-www-form-urlencoded
    
    client_id=aaa&client_secret=bbb&grant_type=client_credentials
    

    You should get a JSON response:

    {"error":"invalid_client"}
    
  3. Support Staff 3 Posted by rune on 04 Mar, 2016 05:00 AM

    rune's Avatar

    Hi again,

    I suspect the issue might be related to the handler configuration in your web.config:

    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
      <add name="ApiURIs-ISAPI-Integrated-4.0_2" path="/api/*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    

    At least this suggests that requests to the /API endpoint should be handled differently than the defaults, so if the /API routes work as expected this might be worth looking into.

    Also, do you use IIS/IISexpress when testing locally? The configuration in the project files seems to indicate that a custom owin host is used during debugging. Using IIS (and likely IIS express) would bring the debugging environment closer to the AppHarbor environment, and might very well explain why you don't see the issue locally (as the handlers configuration referenced above is specific to IIS).

    Best,
    Rune

Discussions are closed to public comments.
If you need help with AppHarbor please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac