我遵循几个教程和 IdentityServer4 文档及其术语:术语 但我不明白从哪个端点获取用户的 id 令牌。 我想我可以改变现有的方式来获得访问令牌来获取 id 令牌,但是没有一种方法给出结果:
var disco = new DiscoveryClient("http://localhost:55678");
var discoResponse = disco.GetAsync().Result;
if (discoResponse.IsError)
{
return null;
}
var tokenClient = new TokenClient(discoResponse.TokenEndpoint, "mvc", "secret");
var tokenResponse = tokenClient.RequestResourceOwnerPasswordAsync(context.EmailAddress, context.Password, "email");
var token = tokenResponse.Result;
我了解resourceownerpassword方式仅用于使用密码访问资源,而不是用于识别用户。
当我尝试配置我的 jwtendpoint 时,我以为我可以询问 id 令牌,但没有结果:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(opts =>
{
opts.Authority = "http://localhost:55678/";
opts.Audience = "api1";
opts.RequireHttpsMetadata = false;
opts.SaveToken = true;
});
我不知道哪个端点用户可以获得jwt id令牌。