aspnet / AspNetKatana

Microsoft's OWIN implementation, the Katana project
Apache License 2.0
963 stars 332 forks source link

Could not load type 'System.IdentityModel.Tokens.TokenValidationParameters' from assembly 'System.IdentityModel.Tokens.Jwt, Version=6.5.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 #374

Closed Ayvid closed 4 years ago

Ayvid commented 4 years ago

I m getting this error when on IDS bearer Token auth UseIdentityServerBearerTokenAuthentication . app framework 4.6 Identity Model - 3.8 here is the package info attached : - packageInfo.txt

Please help

Tratcher commented 4 years ago

You have <package id="Microsoft.Owin.Security.OpenIdConnect" version="4.1.0" targetFramework="net461" /> And <package id="Microsoft.Owin.Security.Jwt" version="3.0.1" targetFramework="net461" />

There were significant breaks in the IdentityModel dependencies between 3.x and 4.x. All Microsoft.Owin packages need to be 4.1.0.

Ayvid commented 4 years ago

Thank you for the response @Tratcher I want to specify few thing about my application here : - 1) It is a web application and we have openIdConnect and cookieAuth functional for this app with IdentityModel 3.8 2) its n -layered , and my web app is calling multi apis integrated with in the same solution.

Now we want to implement ids Bearer Token Auth for that I added IdentityServer3.AccessTokenValidation version="2.11.0" so, after i updated the packages for Owin to 4.1.0 as suggested , i can see the updated versions in the web config as well but now too I get this error :
'Could not load type 'Microsoft.Owin.Security.Jwt.IIssuerSecurityTokenProvider' from assembly 'Microsoft.Owin.Security.Jwt, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.'

and here is the package info attached: - packageInfo (1).txt

Please advise.

Tratcher commented 4 years ago

Your dependencies are still out of sync, something in your graph depends on Microsoft.Owin.Security.Jwt 3.x and needs to be updated. If it can't be then you'll need to downgrade Microsoft.Owin.* to 3.1.

Ayvid commented 4 years ago

ok , let me try that , will let u know

Ayvid commented 4 years ago

@Tratcher i verified dependencies of all the packages that i m using for this app, most of them are having owin dependency >=2x or >= 3x . it seems they should be compatible , but the point is i upgraded Owin to 4.1 so i can't downgrade it now,

do we have any way to catch this dependent package causing this error?

Ayvid commented 4 years ago

i had gone through the similar issue described here https://github.com/IdentityServer/IdentityServer3.AccessTokenValidation/issues/165 . do we have any on going issue with latest version? Please help

Tratcher commented 4 years ago

Indeed, it looks like IdentityServer3.AccessTokenValidation is stuck with an old dependency on Microsoft.Owin.Security.Jwt 3.0.1. There were breaking changes in 4.0 so if you want to continue using IdentityServer3.AccessTokenValidation you'll need to continue using Microsoft.Owin.Security.Jwt 3.x (and 3.x for all Microsoft.Owin packages).

Ayvid commented 4 years ago

thank you , yes you are correct !!, I too just found the same errors relating to IdentityServer3.AccessTokenValidation. This is the error i was able to track. Exception thrown: 'System.TypeLoadException' in IdentityServer3.AccessTokenValidation.dll An exception of type 'System.TypeLoadException' occurred in IdentityServer3.AccessTokenValidation.dll but was not handled in user code Could not load type 'Microsoft.Owin.Security.Jwt.IIssuerSecurityTokenProvider' from assembly 'Microsoft.Owin.Security.Jwt, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

ghost commented 4 years ago

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.