Compile Error: SecurityTokenExpiredException exists in both 'Microsoft.IdentityModel.Tokens' and 'Microsoft.IdentityModel'
See original GitHub issueHi there,
Looking for some guidance around this particular compilation issue.
Packages in use that are conflicting on the type "SecurityTokenExpiredException " which I’m catching in try/catch block:
<package id="Microsoft.IdentityModel" version="6.1.7600.16394" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Tokens" version="5.2.4" targetFramework="net45" />
These packages are referenced by the SharePointPnPCoreOnline - however I don’t think the problem lies with them?
Those packages are:
<package id="SharePointPnP.IdentityModel.Extensions" version="1.2.4" targetFramework="net45" />
<package id="SharePointPnPCoreOnline" version="3.1.1809" targetFramework="net45" />
Example code usage:
bool contextTokenExpired = false;
try
{
if (SharePointContextProvider.Current.GetSharePointContext(httpContext) != null)
{
return RedirectionStatus.Ok;
}
}
catch (SecurityTokenExpiredException)
{
contextTokenExpired = true;
}
Full error:
Severity Code Description Project File Line Suppression State
Error CS0433 The type 'SecurityTokenExpiredException' exists in both 'Microsoft.IdentityModel.Tokens, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ... ...\SharePointContext.cs 333 N/A
Any guidance would be greatly appreciated!
Cheers
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:14 (7 by maintainers)
Top Results From Across the Web
The type 'SecurityTokenDescriptor' exists in both 'Microsoft. ...
The type 'SecurityTokenDescriptor' exists in both 'Microsoft.IdentityModel.Tokens, Version=5.6.0.0' and 'Microsoft.IdentityModel, Version=3.5.0.
Read more >How To use GetAppOnlyAuthenticatedContext when ...
You can handle this in one of two ways: 1. Fully qualify the type. catch (Microsoft.IdentityModel.Tokens.SecurityTokenExpiredException) ...
Read more >SecurityTokenExpiredException Class
Initializes a new instance of the SecurityTokenExpiredException class using the specified error message. SecurityTokenExpiredException(String, Exception).
Read more >The type 'SecurityTokenDescriptor' exists in both 'Microsoft ...
Coding example for the question The type 'SecurityTokenDescriptor' exists in both 'Microsoft.IdentityModel.Tokens, Version=5.6.0.0' and 'Microsoft.
Read more >SecurityTokenExpiredException reported in Azure #10625
That error is thrown by System.IdentityModel.Tokens.Jwt.ValidateToken method, (see:https://docs.microsoft.com/en-us/dotnet/api/system.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a bandaid, I’m making the catch less specific and invalidating the token on any exception.
Hey @brentschmaltz,
Is the core nuget package that references the two conflicting IdentityModel packages.
Is that what you’re looking for?