2016-09-22 11 views
10

मेरे पास एएसपी.नेट एमवीसी 4.5.2 पर चल रही एक वेबसाइट है। मैं एक IdentityServer4 सर्वर चल रहा है, लेकिन जब मैं कोशिश करते हैं और इसके खिलाफ प्रमाणित मैं एक:एएसपी.नेट एमवीसी 4.5.2 पहचान से कनेक्टरसेवर 4

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 पैकेज शामिल कर रहा हूँ मेरी परियोजना माइक्रोसॉफ्ट.ऑविन। सुरक्षा। ओपनआईडी कनेक्ट। मेरा कोड निम्नानुसार है:

 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

ठीक है मुझे यह काम मिल गया।

आपको अपने समाधान Microsoft.Owin.Security.OpenIdConnect पर निम्नलिखित NuGet पैकेज जोड़ने की आवश्यकता है।

मेरे 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 में मेरा ग्राहक config है:

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

मेरे लिए यह उरी को अतिरिक्त "साइनइन-ओडसी" के बिना काम करता था। –

+0

धन्यवाद! मैंने कल इस पर बहुत समय खो दिया और अब यह आखिरकार काम करता है! –

संबंधित मुद्दे