首页 新闻 会员 周边

IdentityServer4授权码模式不能获取授权码?

0
悬赏园豆:10 [已解决问题] 解决于 2020-11-30 16:13

IdentityServer4 版本:4.1.1.0
.Net Core3.1

url:http://localhost:5000/connect/authorize?client_id=apiClientCode&redirect_uri=http://localhost:5003/auth/index&response_type=code&scope=secretapi

client配置: new Client{
ClientId = "apiClientCode",
ClientSecrets = { new Secret("123456".Sha256()) },
AllowedGrantTypes = GrantTypes.Code,
RedirectUris = {"http://localhost:5003/auth/index"},//跳转登录到的客户端的地址
AllowedScopes = new List<string>
{
"secretapi"
}
}

控制台错误截图:

fail: IdentityServer4.Endpoints.AuthorizeEndpoint[0]
Request validation failed
info: IdentityServer4.Endpoints.AuthorizeEndpoint[0]
{
"ClientId": "apiClientCode",
"RedirectUri": "http://localhost:5003/auth/index",
"AllowedRedirectUris": [
"http://localhost:5003/auth/index"
],
"SubjectId": "anonymous",
"ResponseType": "code",
"ResponseMode": "query",
"GrantType": "authorization_code",
"RequestedScopes": "",
"PromptMode": "",
"Raw": {
"client_id": "apiClientCode",
"redirect_uri": "http://localhost:5003/auth/index",
"response_type": "code",
"scope": "secretapi"
}
}

< >
分享
最佳答案
1

1.AllowedScopes 增加:
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
2.redirect_uri 默认应该是 http://localhost:5003/signin-oidc。不清楚你是否重新配置了。

收获园豆:10
gt1987 | 小虾三级 |园豆:1150 | 2020-11-23 14:17

也这样试了试,跳转到登录页面,但是ReturnUrl跟的是一个指向Error页面的url,登录之后直接跳转错误页面

我想啸天 | 园豆:79 (初学一级) | 2020-11-26 14:26

@我想啸天: 贴下你的客户端startup注册配置和identityserver 的client 配置

gt1987 | 园豆:1150 (小虾三级) | 2020-11-26 19:36

@gt1987: 问题已解决,配置问题

我想啸天 | 园豆:79 (初学一级) | 2020-11-30 16:13

@我想啸天: 怎么解决的,说明一下,谢谢

雨一直下哗啦啦 | 园豆:202 (菜鸟二级) | 2021-01-08 17:30
其他回答(1)
0

"redirect_uri": "http://localhost:5003/auth/index/signin-oidc"

 

这样试一下

小小高 | 园豆:1095 (小虾三级) | 2020-11-19 22:34

好的 谢谢

支持(0) 反对(0) 我想啸天 | 园豆:79 (初学一级) | 2020-11-20 09:14

不可以的

支持(0) 反对(0) 我想啸天 | 园豆:79 (初学一级) | 2020-11-20 09:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册