Tag: federated identity

解码Azure移动服务JWT令牌时出现JwtSecurityTokenexception

以下代码: using System.IdentityModel.Tokens; JwtSecurityToken jwtSecurityToken = new JwtSecurityToken(rawToken); 生成以下exception: Jwt10113: Unable to decode the ‘header’ The value “0” is not of type “System.String” and cannot be used in this generic collection. Parameter name: value 当rawToken的’header’部分是: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6MH0 哪个可以解码为: {“alg”:”HS256″,”typ”:”JWT”,”kid”:0} 错误令牌的来源是Azure Mobile Services 。 请注意,调用同一行代码时不会发生exception,而’header’部分是: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjAifQ 哪个可以解码为: {“alg”:”HS256″,”typ”:”JWT”,”kid”:”0″} 我如何克服这个问题,并正确validation这样的令牌?