2017-08-08 24 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