我是identityserver4的新手,所以如果我说错了什么,请纠正我。我已经为用户管理设置了identityserver4和ASP标识,并使用它保护了我的API,但是我不知道如何获得访问令牌,而不必重定向到登录页面。我使用postman通过授权选项卡获取访问令牌,详细信息如下:
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请求体传递一个用户名和密码,并获得一个访问令牌。我做错了什么?
发布于 2020-12-23 12:30:36
您可以添加一个接受客户端凭据流的客户端,使用这个流,您可以使用用户名和密码获得一个访问令牌。这是一个不涉及人类用户的机器对机器通信的流程。
阅读更多关于这里的信息
https://stackoverflow.com/questions/65428337
复制相似问题