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
這幾乎完全解決了我的問題。姓名和電子郵件在context.RequestedClaimTypes中可用,但主題仍不可用。我將JwtClaimTypes.Subject添加到UserClaims。我添加了「my_api」,「openid」,「profile」,「email」。在客戶端,我添加了AllowedScopes:「my_api」,「openid」,「profile」,「email」,「sub」。在Postman中,作用域包含「my_api openid配置文件電子郵件」。 – Uros
默認情況下,JwtClaimTypes.Subject(「sub」)聲明將包含在API中的User.Claims中。 – Uros