我正在使用IdSrv3進行身份驗證。我需要在我的web api owin客戶端中獲取access_token,以在另一個web api客戶端傳遞承載認證。 我Startup.cs代碼:在web api客戶端訪問令牌客戶端IdSrv3身份驗證
public class Startup
{
public void Configuration(IAppBuilder app)
{
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
JwtSecurityTokenHandler.InboundClaimTypeMap.Clear();
var identityServerPath = ConfigurationManager.AppSettings["IdentityServerPath"];
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = $"{identityServerPath}/core",
RequiredScopes = new[] { "openid"},
AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Active,
// client credentials for the introspection endpoint
ClientId = "someid"
});
}
}
我想通過這種方式來獲得訪問令牌:
var claims = (User as ClaimsPrincipal).Claims;
var AccessToken = claims.First(x => x.Type == "access_token").Value;
如何獲得ACCESS_TOKEN?聲明變量是空的。
在那裏有問題嗎? :) –
@JohnKorsnes修正:) –
酷:)請爲下一個開發人員提供一個答案,如果它可以使其他人受益:) –