When I try to transfer this JWT (released by Azure Mobile Services) as the HTTP header / authorization token / media:
Header: { "alg": "HS256", "typ": "JWT", "kid": "0" } Claims: { "ver": 2, "aud": "Facebook", "iss": "urn:microsoft:windows-azure:zumo", "urn:microsoft:credentials": "pYK8b5...", "exp": 1436730730, "uid": "Facebook:10000xxxxxxxxxx" }
In my ASP.NET WEB API:
const string issuer = "urn:microsoft:windows-azure:zumo"; byte[] mobileServicesSecret = TextEncodings.Base64Url.Decode(ConfigurationManager.AppSettings["as:SecretKey"]); app.UseJwtBearerAuthentication( new JwtBearerAuthenticationOptions { AuthenticationMode = AuthenticationMode.Active, AllowedAudiences = new[] { "Facebook" }, IssuerSecurityTokenProviders = new IIssuerSecurityTokenProvider[] { new SymmetricKeyIssuerSecurityTokenProvider(issuer, mobileServicesSecret) } });
I get:
The first random exception of type 'System.IdentityModel.Tokens.SecurityTokenSignatureKeyNotFoundException' occurred in System.IdentityModel.Tokens.Jwt.dll
I suspect this is due to the presence of the "kid" property?
EDIT: Using https://github.com/Magenic/JWTvalidator/tree/master/JwtValidator/JwtValidator , you can check the JWT, so there is nothing wrong with that. But I really want to use OWIN / Katana.
c # asp.net-web-api katana jwt
Magnus johansson
source share