I am getting the below error in WebApi2 project:
Could not load file or assembly \'System.IdentityModel.Tokens.Jwt, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf
In my case adding binding redirect helps.
I have a windows service application, which consumes Microsoft.Owin.Security.Jwt (3.0.1) and System.IdentityModel.Tokens.Jwt (4.0.20622.1351); As I can see, Microsoft.Owin.Security.Jwt (3.0.1) has reference to the System.IdentityModel.Tokens.Jwt (4.0.0) [katanaproject]:
False
..\..\packages\System.IdentityModel.Tokens.Jwt.4.0.0\lib\net45\System.IdentityModel.Tokens.Jwt.dll
The exception mentioned above has ocured exactly when the call was made:
app.UseJwtBearerAuthentication(new CustomJwtOptions());
So I can conclude that package Microsoft.Owin.Security.Jwt (3.0.1) tries to load System.IdentityModel.Tokens.Jwt (4.0.0)
EDIT
We have simple .net app, which is distributed with app.exe.config file. Modifying the file helps to solve the problem mentioned: