2016-09-22 8 views
10

私はWebサイトをASP.NET MVC 4.5.2で実行しています。私はIdentityServer4サーバが実行されているが、私は試してみて、それに対して認証時に私が取得:ASP.NET MVC 4.5.2 IdentityServer4に接続

invalid_request 

ASP.NETコアMVCについてdocumentationがあります

app.UseCookieAuthentication(new CookieAuthenticationOptions 
{ 
    AuthenticationScheme = "Cookies" 
}); 
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 
{ 
    AuthenticationScheme = "oidc", 
    SignInScheme = "Cookies", 

    Authority = "http://localhost:5000", 
    RequireHttpsMetadata = false, 

    ClientId = "mvc", 
    SaveTokens = true 
}); 

私は、次のNuGetパッケージを含めています私のプロジェクトMicrosoft.Owin.Security.OpenIdConnect。次のように私のコードは次のとおりです。

 app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationType = "Cookies" 
     }); 
     app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions 
     { 
      AuthenticationType = "oidc", 
      SignInAsAuthenticationType = "Cookies", 

      Authority = "http://localhost:5000", 

      ClientId = "mvc", 
     }); 

はどのようにして、正しくそれに接続するのでしょうか?

+0

ログはIdentityServer4アプリケーションに言うのです何を?いくつかのログを追加します。 – Lutando

+0

こんにちは、私は同じことをしようとしています...あなたはこれまでに仕事をしましたか? でも動作しますか? –

+0

@ JalalEl-Shaerが回答を追加しました。それが役に立てば幸い。 – Liam

答えて

8

いいえこれはうまくいきました。

ソリューションに次のNuGetパッケージを追加する必要があります。Microsoft.Owin.Security.OpenIdConnect

マイStartup.Auth.cs

public void ConfigureAuth(IAppBuilder app) 
     { 

      app.UseCookieAuthentication(new CookieAuthenticationOptions 
      { 
       AuthenticationType = "Cookies" 
      }); 

      app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions 
      { 
       Authority = "http://localhost:5000", //ID Server 
       ClientId = "demo", 
       ResponseType = "id_token code", 
       SignInAsAuthenticationType = "Cookies", 
       RedirectUri = "http://localhost:51048/signin-oidc", //URL of website 
       Scope = "openid",    
      }); 

     } 

IdentityServerで私のクライアントの設定が含まれています

public static IEnumerable<Client> GetClients() 
     { 
      return new List<Client> { 
       new Client { 
        ClientId = "demo", 
        AllowedScopes = new List<string> { "openid"}, 
        AllowedGrantTypes = GrantTypes.Hybrid, 
        RedirectUris = new List<string>{"http://localhost:51048/signin-oidc"}, 

       } 
      }; 
     } 
+0

私にとって、それはウリに余分な "サインイン - oidc"なしで働いた。 –

+0

ありがとう!私は昨日これで多くの時間を失いました。 –

関連する問題