是否可以仅通过 REST 调用在 identityserver4 中进行身份验证?

Is it possible to make authentication in identityserver4 only available via REST calls?

我对 identityserver4 很陌生,所以如果我说错了请纠正我。我已经为用户管理设置了 identityserver4 和 ASP 身份,并用它保护了我的 API,但是我不知道如何在不必重定向到登录页面的情况下获取访问令牌。我正在使用邮递员使用以下详细信息通过授权选项卡获取访问令牌:

  new Client
  {
     ClientId = "postman-api",
     ClientName = "Postman Test Client",
     ClientSecrets = { new Secret("PostmanIsASecret".Sha256()) },
     AllowedGrantTypes = GrantTypes.Implicit,
     AllowAccessTokensViaBrowser = true,
     RequireConsent = false,
     RedirectUris = { "https://www.getpostman.com/oauth2/callback"},
     PostLogoutRedirectUris = { "https://www.getpostman.com" },
     AllowedCorsOrigins = { "https://www.getpostman.com" },
     EnableLocalLogin = false,
     RequirePkce = false,
     AllowedScopes =
     {
        IdentityServerConstants.StandardScopes.OpenId,
        IdentityServerConstants.StandardScopes.Profile,
        IdentityServerConstants.StandardScopes.Email,
        "jumsum.api"
     }
}

我只想登录并获取访问令牌,而不必一直重定向。在控制台中我得到这个:

IdentityServer4.ResponseHandling.AuthorizeInteractionResponseGenerator: Information: Showing login: User is not authenticated

我只想通过 http 请求正文传递用户名和密码并取回访问令牌。我做错了什么?

您可以添加一个接受 客户端凭据流程 的客户端,使用此流程您可以仅使用用户名和密码获取访问令牌。这是不涉及人类用户的机器对机器通信的流程。

了解更多相关信息 here