1

I am currently using the quick start to get a basic implementation going in my framework I'm building, and I'm busy adding in the following:

 app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
    Authority = "http://localhost:5000",
    RequireHttpsMetadata = false,

    ApiName = "api1"
});

I get the following error

Could not load file or assembly 'Microsoft.IdentityModel.Tokens, 
Version=5.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The problem is that I have installed the nuget packages as explained on the IdentityServer4 site:

IdentityServer4
IdentityServer4.AccessTokenValidation

I've looked through the dependencies and 5.1.3 is installed along with these packages, but for some reason it is looking for 5.1.2.

I've cleared my nuget cache, restarted visual studio numerous times etc...

My code looks like this:

 loggerFactory.Initialise(Configuration.GetSection("Logging"));

        _applicationProvider.ConfigurePreMvc(app, env, serviceProvider);

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        })
        .UseSwagger();

        _applicationProvider.ConfigurePostMvc(app, env, serviceProvider);

and where _applicationProvider.ConfigurePreMvc(app, env, serviceProvider); executes it is executing the following:

  var settings = serviceProvider.GetService<IOptions<Settings>>().Value;

        app
            .UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
            {
                Authority = settings.IdentityServerUrl,
                RequireHttpsMetadata = false,

                ApiName = "api1"
            });

the error happens on .UseIdentityServerAuthentication

Any one else had this problem? Strange how the version is wrong even though it specifies the dependency, I have also tried to download the package myself which is 5.1.4 and then it was suddenly looking for 5.1.3 and not 5.1.2, which is even more confusing...

Lyon
  • 546
  • 6
  • 16
  • Do you have an assembly binding redirect set up in your web.config? –  Jul 07 '17 at 11:02
  • This is asp.net core there isn't a web.config. – Lyon Jul 07 '17 at 11:18
  • Try enable [fusion logging](https://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net) to get more information. – Christian.K Jul 07 '17 at 12:02
  • @Lyon then create a file called app.config and put the redirects there. asp.net core still uses assembly binding redirects –  Jul 07 '17 at 16:55

1 Answers1

0

If your project is just a Web API then you don't need IdentityServer4 package but just IdentityServer4.AccessTokenValidation. Try removing the other package and see if that helps. Check out the official docs!

JayDeeEss
  • 1,075
  • 9
  • 14