I\'m developing a web app with Asp.Net 5 MVC, Owin and Oauth2 bearer token as auth type.
Following this guide that adds a custom complex claim Json serialized to an inst
The cast in GetPassport tries to convert from base type Claim to derived type ComplexClaim which will result in null.
You need to write a cast operator to convert from Claim to UKPassport
public static explicit operator UKPassport(Claim c)
{
return (c == null ? null:JsonConvert.DeserializeObject (c.Value));
}
and GetPassport will be
private static UKPassport GetPassport(this ClaimsIdentity identity, string passportType)
{
return (UKPassport)identity.Claims.FirstOrDefault(c => c.Type == @"http://it.test/currentpassport");
}