starup.Auth.cs寫了這些
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new AppliApplicationOAuthProvider(),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true
};
AppliApplicationOAuthProvider中重寫了這兩個方法
public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
{
context.Validated();
return Task.FromResult<object>(null);
}
public override async Task GrantResourceOwnerCredentials(
OAuthGrantResourceOwnerCredentialsContext context)
{
var oAuthIdentity = new ClaimsIdentity(context.Options.AuthenticationType);
oAuthIdentity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
var ticket = new AuthenticationTicket(oAuthIdentity, new AuthenticationProperties());
context.Validated(ticket);
await base.GrantResourceOwnerCredentials(context);
}
一直進不去GrantResourceOwnerCredentials這個方法。

這個是我呼叫的json,是呼叫方法有問題么,應該怎么寫?還有貌似context里沒有任何資料
uj5u.com熱心網友回復:
你的grandtype在哪設定的?uj5u.com熱心網友回復:
不知道啊,什么grandtype在哪里設定,剛學習
uj5u.com熱心網友回復:
還有vs2015創建webAPI的時候直接呼叫默認例子的token也會出現unsupported_grant_type是什么情況
uj5u.com熱心網友回復:
https://github.com/MikeWasson/LocalAccountsApp這個例子下載下來,用他的登錄可以進入GrantResourceOwnerCredentials,而直接用網址接字串卻不行,為什么
uj5u.com熱心網友回復:
可以交流下嗎uj5u.com熱心網友回復:
POST應該是鍵值對,不要JSON試試
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/89056.html
標籤:Web Services
