I am trying to configure my authentication using a flow of provision authorization_code. I used to work with grant_type=password, so I know how the material should work. But when using, grant_type=authorization_codeI could not get it to return anything butinvalid_grant
Here is my setup:
app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/auth/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(5),
Provider = new SampleAuthProvider()
});
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
{
AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Active,
AuthenticationType = "Bearer"
});
SampleAuthProvider is the following class: https://gist.github.com/anonymous/8a0079b705423b406c00
Basically, it just logs every step and checks it. I tried the request:
POST http://localhost:12345/auth/token
grant_type=authorization_code&code=xxxxxx&client_id=xxxxx&redirect_uri=https://xxxx.com/
Content-Type: application/x-www-form-urlencoded
Occurs:
OnMatchEndpointOnValidateClientAuthentication
And it's all. I expected that he would call OnValidateTokenRequestand OnGrantAuthorizationCodeon, but it just did not work. I have no idea why.
xxxx , . , - ? redirect_uri http, - , ...
grant_type. , , , , authorization_code, .
TL; DR
My OAuthAuthorizationServerProvider {"error":"invalid_grant"} OnValidateClientAuthentication grant_type=authorization_code.
!
Edit
, . AuthorizationCodeProvider. , AuthorizationCodeProvider, . , .