5

मुझे त्रुटि मिल रही है 'क्लाइंट एप्लिकेशन ज्ञात नहीं है या अधिकृत नहीं है।' मेरी साइट के संरक्षित क्षेत्र तक पहुंचने पर।पहचान सर्वर 3 - क्लाइंट एप्लिकेशन ज्ञात नहीं है या अधिकृत नहीं है

public class Startup 
{ 
    public void Configuration(IAppBuilder app) 
    { 
     app.Map("/identity", idsrvApp => 
     { 
      idsrvApp.UseIdentityServer(new IdentityServerOptions 
      { 
       SiteName = "Authentication Service - Embedded IdentityServer", 
       SigningCertificate = Certificate.LoadCertificate(), 

       Factory = new IdentityServerServiceFactory() 
          .UseInMemoryUsers(Users.Get()) 
          .UseInMemoryClients(Clients.Get()) 
          .UseInMemoryScopes(Scopes.Get()) 
      }); 
     }); 
    } 
} 

यह वह जगह है:

public class Startup 
{ 
    public void Configuration(IAppBuilder app) 
    { 
     app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationType = "Cookies" 
     }); 

     app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions 
     { 
      Authority = UrlManager.AuthenticationService + "identity", 

      ClientId = "webapplication", 
      Scope = "openid profile", 
      ResponseType = "code id_token", 
      RedirectUri = UrlManager.WebApplication, 

      SignInAsAuthenticationType = "Cookies" 
     }); 
    } 
} 

यह मेरा प्रमाणीकरण सेवा (जहां IDS3 स्थापित किया गया है) स्टार्टअप है:

public static class Clients 
{ 
    public static IEnumerable<Client> Get() 
    { 
     return new[] 
     { 
      new Client 
      { 
       Enabled = true, 
       ClientName = "Web Application", 
       ClientId = "webapplication", 
       Flow = Flows.AuthorizationCode, 

       ClientSecrets = new List<Secret> 
       { 
        new Secret("webappsecret".Sha256()) 
       }, 

       RedirectUris = new List<string> 
       { 
        UrlManager.WebApplication 
       }, 
       PostLogoutRedirectUris = new List<string> 
       { 
        UrlManager.WebApplication 
       }, 

       AllowedScopes = new List<string> 
       { 
        Constants.StandardScopes.OpenId, 
        Constants.StandardScopes.Profile, 
        Constants.StandardScopes.Email, 
        Constants.StandardScopes.Roles, 
        Constants.StandardScopes.OfflineAccess, 
        "read", 
        "write" 
       } 
      } 
     }; 
    } 
} 

यहाँ मेरी वेब अनुप्रयोग स्टार्टअप है:

यहाँ मेरी ग्राहक है UrlManager:

public static class UrlManager 
{ 
    public static string WebApplication 
    { 
     get { return "https://localhost:44381/"; } 
    } 

    public static string AuthenticationService 
    { 
     get { return "https://localhost:44329/"; } 
    } 
} 

यह मेरा घर नियंत्रक है: '। क्लाइंट अनुप्रयोग ज्ञात नहीं है या अधिकृत नहीं है'

public class HomeController : Controller 
{ 
    public ActionResult Index() 
    { 
     return View(); 
    } 

    [Authorize] 
    public ActionResult Private() 
    { 
     return View((User as ClaimsPrincipal).Claims); 
    } 
} 

जब मैं निजी मैं एक पहचान सर्वर 3 स्क्रीन है कि मुझे देता त्रुटि संदेश मिलता है का उपयोग।

मैंने पढ़ा है कि यह रीडायरेक्ट यूआरआई में गलत मिलान से आ सकता है लेकिन जहां तक ​​मैं देख सकता हूं कि मेरा सही है। मुझे नहीं पता कि इसका और क्या कारण हो सकता है। यदि मैं प्रवाह को अंतर्निहित में बदलता हूं तो एप्लिकेशन पूरी तरह से काम करता है लेकिन मैं प्राधिकरण कोड प्रवाह को कार्यान्वित करना चाहता हूं।

प्रलेखन इस पर कोई प्रकाश नहीं दिखता प्रतीत होता है।

उत्तर

8

ग्राहक प्राधिकरण कोड के लिए कॉन्फ़िगर किया गया था प्रवाह

प्रवाह = Flows.AuthorizationCode

लेकिन स्टार्टअप में प्रतिक्रिया प्रकार संकर प्रवाह को तैयार है।

ResponseType = "कोड id_token"

को

ResponseType इस बदलने का प्रयास करें = "code" (या हाइब्रिड के प्रवाह प्रकार बदलें)

नीचे है ResponseType और संबंधित प्रवाह की सूची enter image description here

0

मुझे यह त्रुटि मिली, और समस्या यह थी कि RedirectUri। प्राधिकरण सर्वर में http://localhost:56840/ और वेब ऐप में http://localhost:56840 था। यूआरएल के अंत में लापता "/" नोट करें।

+0

मुझे यह पता चलेगा कि आपने इसे कैसे ठीक किया है, अगर यह वास्तविक गलती थी। चियर्स – Ian

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