IdentityServer4 500内部错误,使用授权端点时缺少EpochTimeExtensions

时间:2019-06-01 11:59:41

标签: c# asp.net identityserver4

我正在使用ASP.NET为xamarin表单应用程序创建一个wep api后端, 我正在使用identityserver4进行身份验证和授权。 我想使用授权码工作流程,但是尝试启动授权/身份验证请求时遇到问题。

我收到的错误是: System.TypeLoadException:无法从程序集“ IdentityModel,版本= 4.0.0.0,区域性=中性,PublicKeyToken = e7877f4675df049f”中加载类型“ IdentityModel.EpochTimeExtensions”。

我在互联网上的任何地方都没有找到解决此问题的方法。

这是我的Startup.cs

public class Startup
{
    public IConfiguration Configuration { get; }

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }


    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        //services.AddAutoMapper();
        services.AddDbContext<SqlDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
        services.AddScoped<IUnitOfWork, UnitOfWork>();
        services.AddIdentityServer()
            .AddInMemoryIdentityResources(Config.GetResources())
            .AddInMemoryApiResources(Config.GetApis())
            .AddInMemoryClients(Config.GetClients())
            .AddDeveloperSigningCredential();
        services.AddControllers()
            .AddNewtonsoftJson();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }

        app.UseHttpsRedirection();

        app.UseRouting();

        app.UseIdentityServer();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
            endpoints.MapGet("/", async context =>
            {
                await context.Response.WriteAsync("Hello World !");
            });
        });
    }
}

这是我的config.cs:

public class Config
{
    public static IEnumerable<ApiResource> GetApis()
    {
        return new List<ApiResource>
        {
            new ApiResource("Test", "TestService")
        };
    }

    public static IEnumerable<IdentityResource> GetResources()
    {
        return new List<IdentityResource>
        {
            new IdentityResources.OpenId()
        };
    }

    public static IEnumerable<Client> GetClients()
    {
        return new List<Client>
        {
            new Client
            {
                ClientId = "client",
                AllowedGrantTypes = GrantTypes.Code,
                RequireClientSecret = false,
                RequireConsent = false,
                AllowedScopes = new List<string>{ "Test" , "openid"},
                AllowOfflineAccess = true,
                RedirectUris = new List<String> {
                    "https://localhost:44392/account/test/"
                }
            }
        };
    }
 }

这是我的请求网址:

https://localhost:44392/connect/authorize?client_id=client&response_type=code&redirect_uri=https://localhost:44392/account/test/&scope=Test openid&nonce = 5&state = 5

我希望这里有人可以帮助我。 预先感谢

0 个答案:

没有答案