该IdentityServerTools
是为IdentityServer编写扩展代码时,你可能需要有效的内部工具的集合。要使用它,请将其注入代码,例如控制器:
public MyController(IdentityServerTools tools)
{
_tools = tools;
}
该IssueJwtAsync
方法允许使用IdentityServer令牌创建引擎创建JWT令牌。这IssueClientJwtAsync
是为服务器到服务器通信创建令牌的简单版本(例如,当您必须从代码中调用受IdentityServer保护的API时):
public async Task<IActionResult> MyAction()
{
var token = await _tools.IssueClientJwtAsync(
clientId: "client_id",
lifetime: 3600,
audiences: new[] { "backend.api" });
// more code
}