Внутренняя ошибка IdentityServer4 500, ошибка EpochTimeExtensions при использовании конечной точки авторизации - PullRequest
0 голосов
/ 01 июня 2019

Я создаю серверную часть wep api для приложения форм xamarin с ASP.NET, я использую identityserver4 для аутентификации и авторизации.Я хочу использовать рабочий процесс кода авторизации, но у меня возникает проблема при попытке запустить запрос авторизации / аутентификации.

Полученная ошибка: System.TypeLoadException: Не удалось загрузить тип 'IdentityModel.EpochTimeExtensions«из сборки» IdentityModel, версия = 4.0.0.0, культура = нейтральная, PublicKeyToken = e7877f4675df049f '.

Я не нашел решения этой проблемы в Интернете.

Этомой 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/"
                }
            }
        };
    }
 }

И это мой URL-адрес запроса:

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

Я надеюсь, что кто-то здесь может мне помочь.Заранее спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...