Ok the issue here is this:
although you have configured your available Identity resources correctly (both standard & custom), you also need to explicitly define which ones are a necessity when calling your api resource. In order to define this you must go to your Config.cs
class on ExampleIdentityServer
project and provide a third argument like on the new ApiResouirce
constructor. Only those will be included into the access_token
// scopes define the API resources in your system
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource("api1", "My API", new[] { JwtClaimTypes.Subject, JwtClaimTypes.Email, JwtClaimTypes.Phone, etc... })
};
}
In essence this means that I got my identity claims configured for my organization but there may be more than one APIs involved and not all of the APIs make use of all available profile claims. This also means that these will be present inside your ClaimsPrincipal
all the rest can still be accessed through the "userinfo" endpoint as a normal http call.
NOTE: regarding refresh tokens:
If you chose to enable refresh tokens via AllowOfflineAccess = true
, you may experience the same behavior upon refreshing the access_token "GetProfileDataAsync does not execute!". So the claims inside the access_token stay the same although you get a new access_token with updated lifetime. If that is the case you can force them to always refresh from the Profile service by setting UpdateAccessTokenClaimsOnRefresh=true
on the client configuration.