身份服务器 4,Asp.net 身份和
identity server 4, Asp.net identity and
我正在尝试将身份服务器 4 与 asp.net 身份集成,文档非常好 https://identityserver4.readthedocs.io/en/latest/quickstarts/6_aspnet_identity.html
但我希望能够不通过登录页面建立连接,而是在传递参数时通过简单的 GET 直接访问。
用这个方法
var response = await _httpClient.RequestPasswordTokenAsync(new PasswordTokenRequest
{
Address = _disco.TokenEndpoint,
ClientId = "resourceownerclient",
ClientSecret = "dataEventRecordsSecret",
Scope = "email openid dataEventRecords offline_access",
UserName = user,
Password = password
});
但无法与 Postman 一起使用
我有一个“invalid_request”错误
客户声明如下:
new Client
{
ClientId = "resourceownerclient",
AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
AccessTokenType = AccessTokenType.Jwt,
AccessTokenLifetime = 3600,
IdentityTokenLifetime = 3600,
UpdateAccessTokenClaimsOnRefresh = true,
SlidingRefreshTokenLifetime = 30,
AllowOfflineAccess = true,
RefreshTokenExpiration = TokenExpiration.Absolute,
RefreshTokenUsage = TokenUsage.OneTimeOnly,
AlwaysSendClientClaims = true,
Enabled = true,
ClientSecrets= new List<Secret> { new Secret("dataEventRecordsSecret".Sha256()) },
AllowedScopes = {
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
IdentityServerConstants.StandardScopes.OfflineAccess,
"dataEventRecords"
},
AllowAccessTokensViaBrowser=true
}
能够以这种方式使用 Asp.net 身份的推荐方法是什么?
您的邮递员请求中缺少 grant_type
:
POST /connect/token
client_id=resourceownerclient&
client_secret=dataEventRecordsSecret&
grant_type=password&
username=damienbod&
password=damienbod&
scope=email%20openid%20dataEventRecords%20offline_access
不确定这是否是您遇到的唯一问题,但绝对是其中之一。如果这不是唯一的问题,身份服务器日志将包含有关请求错误的更多详细信息。
我正在尝试将身份服务器 4 与 asp.net 身份集成,文档非常好 https://identityserver4.readthedocs.io/en/latest/quickstarts/6_aspnet_identity.html
但我希望能够不通过登录页面建立连接,而是在传递参数时通过简单的 GET 直接访问。
用这个方法
var response = await _httpClient.RequestPasswordTokenAsync(new PasswordTokenRequest
{
Address = _disco.TokenEndpoint,
ClientId = "resourceownerclient",
ClientSecret = "dataEventRecordsSecret",
Scope = "email openid dataEventRecords offline_access",
UserName = user,
Password = password
});
但无法与 Postman 一起使用
我有一个“invalid_request”错误
客户声明如下:
new Client
{
ClientId = "resourceownerclient",
AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
AccessTokenType = AccessTokenType.Jwt,
AccessTokenLifetime = 3600,
IdentityTokenLifetime = 3600,
UpdateAccessTokenClaimsOnRefresh = true,
SlidingRefreshTokenLifetime = 30,
AllowOfflineAccess = true,
RefreshTokenExpiration = TokenExpiration.Absolute,
RefreshTokenUsage = TokenUsage.OneTimeOnly,
AlwaysSendClientClaims = true,
Enabled = true,
ClientSecrets= new List<Secret> { new Secret("dataEventRecordsSecret".Sha256()) },
AllowedScopes = {
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
IdentityServerConstants.StandardScopes.OfflineAccess,
"dataEventRecords"
},
AllowAccessTokensViaBrowser=true
}
能够以这种方式使用 Asp.net 身份的推荐方法是什么?
您的邮递员请求中缺少 grant_type
:
POST /connect/token
client_id=resourceownerclient&
client_secret=dataEventRecordsSecret&
grant_type=password&
username=damienbod&
password=damienbod&
scope=email%20openid%20dataEventRecords%20offline_access
不确定这是否是您遇到的唯一问题,但绝对是其中之一。如果这不是唯一的问题,身份服务器日志将包含有关请求错误的更多详细信息。