Getting an Invalid Cast Exception if I call the GetClaimValue method below where T is a nullable int.
private static T GetClaimValue<T>(string claimType, IEnumerable<Claim> claims)
{
var claim = claims.SingleOrDefault(c => c.Type == claimType);
if (claim != null)
return (T) Convert.ChangeType(claim.Value, typeof(T));
return default(T);
}
For example:
GetClaimValue<int?>(IdentityServer.CustomClaimTypes.SupplierId, claims)
Anyone know of a way to deal with this?