Skip to content

OAuth token endpoint returns 500 instead of 400 when authorization_code is missing code #538

Open
@MagicShoebox

Description

@MagicShoebox
app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions { TokenEndpointPath = "/token" });
irm -Method POST -Body @{ grant_type = "authorization_code" } https://localhost:8080/token

This returns 500 instead of 400.

OAuthAuthorizationServerHandler.InvokeTokenEndpointAuthorizationCodeGrantAsync() triggers an ArgumentNullException on line 489 when it tries to construct an AuthenticationTokenReceiveContext with a null token (tokenEndpointRequest.AuthorizationCodeGrant.Code).

I'm not quite sure why AuthenticationTokenReceiveContext throws this exception. I think it (and its consumers) should probably handle the case where token is null. Alternatively, InvokeTokenEndpointAuthorizationCodeGrantAsync() should check that a code was provided. Happy to open a PR given guidance on which approach to take.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions