2017-08-08 31 views
0

我正在关注post来实现IdentityServer4。我有在过程GetProfileDataAsync中的ProfileService中的问题IEnumerable context.RequestedClaimTypes为空。我应该在Postman中更改我的请求以请求某些索赔类型吗?我能做些什么,以便context.RequestedClaimTypes包含声明类型?如何请求IdentityServer4中的声明类型?

我的邮差请求如下所示:

Post http://localhost:57577/connect/token 
Authorization: Basic Z2xvYmFsX2F... 
Body (x-www-form-urlencoded): 
username:[email protected] 
password:pass 
grant_type:password 
scope:my_api 

回答

1

就像你跟着后,您有权要求它在你的scope。你可以添加profile email,然后你应该得到这些声明。请确保您将它们添加到AllowedScopes下的客户端配置(config.cs)中。

+0

这几乎完全解决了我的问题。姓名和电子邮件在context.RequestedClaimTypes中可用,但主题仍不可用。我将JwtClaimTypes.Subject添加到UserClaims。我添加了“my_api”,“openid”,“profile”,“email”。在客户端,我添加了AllowedScopes:“my_api”,“openid”,“profile”,“email”,“sub”。在Postman中,作用域包含“my_api openid配置文件电子邮件”。 – Uros

+0

默认情况下,JwtClaimTypes.Subject(“sub”)声明将包含在API中的User.Claims中。 – Uros