I'm trying out IdentityServer4 demo project and I'm adding user claims to ProfileDataRequestContext.IssuedClaims
in IProfileService
implementation. One thing I've noticed is that there is a context.RequestedClaimTypes
collection, which is always empty in any resource/identity/scope configuration variations I've tried. Under what condition does this collection has data?
If in the definition of your ApiResources
you define UserClaims
, these will then be populated in the context.RequestClaimTypes
.
For example:
new ApiResource
{
Name = "TestAPI",
ApiSecrets = { new Secret("secret".Sha256()) },
UserClaims = {
JwtClaimTypes.Email,
JwtClaimTypes.EmailVerified,
JwtClaimTypes.PhoneNumber,
JwtClaimTypes.PhoneNumberVerified,
JwtClaimTypes.GivenName,
JwtClaimTypes.FamilyName,
JwtClaimTypes.PreferredUserName
},
Description = "Test API",
DisplayName = "Test API",
Enabled = true,
Scopes = { new Scope("testApiScore) }
}
Then your ProfileDataRequestContext.RequestClaimTypes
will contain these request claims, for your Identity Server to fulfil how you see fit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With