question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Use System.Text.Json instead of Microsoft.IdentityModel.Json

See original GitHub issue

Is your feature request related to a problem? Please describe. When creating token:

var token = JwtSecurityTokenHandler.CreateJwtSecurityToken(
                issuer: issuer,
                audience: audience,
                signingCredentials: credential,
                subject: Identity.Create("pwd", claims));

there is used TokenUtilities.GetClaimValueUsingValueType() method which uses internal types (JArray, JObject from Microsoft.IdentityModel.Json.Linq). Then the System.IdentityModel.Tokens.Jwt.JsonExtensions.Serializer is called where JwtPayload is serialized. But JwtPayload contains objects with internal types (JArray, JObject) and when using custom serializer there is problem to detect how to serialize this object.

So the internal serializer is not quite internal, because its types are required to be public to properly handle library.

Describe the solution you’d like Remove internal Microsoft.IdentityModel.Json serializer and use System.Text.Json.

Describe alternatives you’ve considered Make internal serializer public - accessible from outside of assembly.

Issue Analytics

  • State:open
  • Created 6 months ago
  • Reactions:1
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
brentschmaltzcommented, Apr 25, 2023

@kevinchalet i’ll work to get a commitment from the team.

0reactions
kevinchaletcommented, May 8, 2023

Great, thanks for the information, @brentschmaltz! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrate from Newtonsoft.Json to System.Text.Json - .NET
The System.Text.Json namespace provides functionality for serializing to and deserializing from JavaScript Object Notation (JSON). The System.
Read more >
Consider removing all references to Newtonsoft.Json and ...
Json is a risky task since Microsoft serializer is way less permissive than Newtonsoft. ... Json and use System.Text.Json instead #23353.
Read more >
Should you use Newtonsoft.Json or System.Text. ...
Just be aware of some of the core differences. Newtonsoft for example ignores case deserializing. System.Text.Json matches case for performance ...
Read more >
c# - How do I fix the error "Could not load file or assembly ' ...
The culprit was the this latest version of System.Text.Json (6.0.2) which was not compatible as a dependency for IdentityModel package latest ...
Read more >
Feedback - Please add System.Text.Json support
Text.Json with the right version (using NuGet online website, then decompress the nuget package with 7Zip for example). Use the 5.0.0 version of ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found