0

.NET MVCコアプロジェクトは完璧に動作し、IdentityServer4のセットアップを使用してログインできます。私はJavaScriptクライアントを使用してログインすると同じIdentityServerを使用しようとするしかし、私は以下のエラーに遭遇:私はそれを達成するためにJavaScriptクライアントでoidc-client.jsを使用していますJavaScriptクライアントからIdentityServer4を使用してログインできません

enter image description here

。私はCORSを許可するためにallowCorsの設定をしています。

  services.AddCors(options => 
     { 
      // this defines a CORS policy called "default" 
      options.AddPolicy("default", policy => 
      { 
        policy.AllowAnyOrigin() 
        .AllowAnyHeader() 
        .AllowAnyMethod() 
        .AllowCredentials(); 
      }); 
     }); 

誰かが同じ問題を抱えている場合は助けてください。私はIdentityServer4自体のチュートリアルに従いましたhttp://docs.identityserver.io/en/release/quickstarts/7_javascript_client.html。私はチュートリアルにしたがってすべてのものが整っていることを確認しましたが、問題に直面しています。

これは、ブラウザのコンソールに表示されるエラーです。

enter image description here

+0

クライアントの設定と、JavaScriptで使用されている場所を共有してください。これは通常、一致するリターンURLがないためです。 – aaronR

答えて

0

JSアプリケーションのクライアントエントリがIdentityServerに欠けていたことが判明。

以下のエントリを追加して修正しました。

   // JavaScript Client 
      new Client 
      { 
       ClientId = "js", 
       ClientName = "JavaScript Client", 
       AllowedGrantTypes = GrantTypes.Implicit, 
       AllowAccessTokensViaBrowser = true, 

       RedirectUris =   { "http://localhost:55697/callback.html" }, 
       PostLogoutRedirectUris = { "http://localhost:55697/index.html" }, 
       AllowedCorsOrigins =  { "http://localhost:55697" }, 

       AllowedScopes = 
       { 
        IdentityServerConstants.StandardScopes.OpenId, 
        IdentityServerConstants.StandardScopes.Profile, 
        "api1" 
       } 
      } 
関連する問題