Home > Net >  About the use of a request to obtain in webapi token
About the use of a request to obtain in webapi token

Time:09-27

Startup. The Auth. Cs wrote these

 OAuthOptions=new OAuthAuthorizationServerOptions 
{
TokenEndpointPath=new PathString ("/Token "),
The Provider=new AppliApplicationOAuthProvider (),
AccessTokenExpireTimeSpan=TimeSpan. FromDays (14),
AllowInsecureHttp=true
};


AppliApplicationOAuthProvider rewrite the two methods in
 public override Task ValidateClientAuthentication (OAuthValidateClientAuthenticationContext context) 
{
The context. The Validated ();
The return of Task. FromResult (null);
}
Public override async Task GrantResourceOwnerCredentials (
OAuthGrantResourceOwnerCredentialsContext context)
{
Var oAuthIdentity=new ClaimsIdentity (context. The Options. AuthenticationType);
OAuthIdentity. AddClaim (new Claim (ClaimTypes. The Name, the context. The UserName));
Var ticket=new AuthenticationTicket (oAuthIdentity, new AuthenticationProperties ());
The context. The Validated (ticket);

Await base. GrantResourceOwnerCredentials (context);
}
Always can't get into GrantResourceOwnerCredentials this way,



This is what I call a json, calls the method has a problem, should be how to write? And seems there is no any data in the context of

CodePudding user response:

Where is your grandtype Settings?

CodePudding user response:

reference 1st floor FoxDave response:
where your grandtype Settings?

I don't know, where is what grandtype Settings, just learning

CodePudding user response:

reference 1st floor FoxDave response:
where your grandtype Settings?


And vs2015 directly invoking the default when creating webAPI example of token unsupported_grant_type is what will happen

CodePudding user response:

https://github.com/MikeWasson/LocalAccountsApp

Download this example, use his login can enter GrantResourceOwnerCredentials, and directly use url string cannot, why

CodePudding user response:

Can communicate

CodePudding user response:

POST should be a key/value pair, not JSON
Have a try
  • Related