azure-activedirectory-identitymodel-extensions-for-dotnet
azure-activedirectory-identitymodel-extensions-for-dotnet copied to clipboard
IDX12729: Exception **System.MissingMethodException: Method not found:** thrown when reading the access token.
Which version of Microsoft.IdentityModel are you using? 7.3.1
Where is the issue?
- [ ] S.IM.Tokens.Jwt
Is this a new or an existing app? a. The app is in production and I have upgraded to a new version of Microsoft.IdentityModel.*
Repro Trying to decode the JWT token is resulting into exception. The token is retrieved using certificate and trying to fetch Payload claim values. The exception encountered is:
{"IDX12729: Unable to decode the header 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IkwxS2ZLRklfam5YYndXYzIyeFp4dzFzVUhIMCIsImtpZCI6IkwxS2ZLRklfam5YYndXYzIyeFp4dzFzVUhIMCJ9' as Base64Url encoded string."}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2147024809
HelpLink: null
InnerException: {"Method not found: 'Void System.Text.Json.Utf8JsonReader..ctor(System.ReadOnlySpan1<Byte>, System.Text.Json.JsonReaderOptions)'."} Message: "IDX12729: Unable to decode the header 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IkwxS2ZLRklfam5YYndXYzIyeFp4dzFzVUhIMCIsImtpZCI6IkwxS2ZLRklfam5YYndXYzIyeFp4dzFzVUhIMCJ9' as Base64Url encoded string." ParamName: null Source: "System.IdentityModel.Tokens.Jwt" StackTrace: " at System.IdentityModel.Tokens.Jwt.JwtSecurityToken.Decode(String[] tokenParts, String rawData)\r\n at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ReadJwtToken(String token)\r\n at Kailani.Hfs.V1.Client.AD.AzureADClient.GetPayloadClaimValueFromAccessToken(String claim, String accessToken) in G:\\OneEsWorkingDirectory\\Storage\\XSync\\Dev\\src\\Kailani\\Kailani.Hfs.Client.AD\\AzureADClient.cs:line 690" TargetSite: {Void Decode(System.String[], System.String)} Trace> EventLevel: Error Message: -------Exception information------ System.ArgumentException: IDX12729: Unable to decode the header 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IkwxS2ZLRklfam5YYndXYzIyeFp4dzFzVUhIMCIsImtpZCI6IkwxS2ZLRklfam5YYndXYzIyeFp4dzFzVUhIMCJ9' as Base64Url encoded string. ---> System.MissingMethodException: Method not found: 'Void System.Text.Json.Utf8JsonReader..ctor(System.ReadOnlySpan
1<Byte>, System.Text.Json.JsonReaderOptions)'.
at System.IdentityModel.Tokens.Jwt.JwtHeader..ctor(String json)
at System.IdentityModel.Tokens.Jwt.JwtHeader.Base64UrlDeserialize(String base64UrlEncodedJsonString)
at System.IdentityModel.Tokens.Jwt.JwtSecurityToken.Decode(String[] tokenParts, String rawData)
--- End of inner exception stack trace ---
at System.IdentityModel.Tokens.Jwt.JwtSecurityToken.Decode(String[] tokenParts, String rawData)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ReadJwtToken(String token)
at GetPayloadClaimValueFromAccessToken(String claim, String accessToken) in AzureADClient.cs:line 690
------Begin Inner exception extra info------
------End inner exception extra info-----
It is very interesting that performing a same action in a sample app on my dev box, works fine!! For this App, I have following NuGet Microsoft.IdentityModel.*.7.5.1 System.IdentityModel.Tokens.Jwt.7.5.1 System.Text.Json.4.7.2
var handler = new JwtSecurityTokenHandler();
var jwtToken = handler.ReadJwtToken(accessToken);
return jwtToken.Claims.FirstOrDefault(c => c.Type == claim)?.Value;
Expected behavior A clear and concise description of what you expected to happen (or code).
Actual behavior A clear and concise description of what happens, e.g. an exception is thrown, UI freezes.
Possible solution
Additional context / logs / screenshots / links to code
Add any other context about the problem here, such as logs and screenshots or links to code.