2017-04-25 12 views
1

.netコアでGoogle認証を使用していますが、googleからリダイレクトすると例外が表示されます - InvalidOperationException:スキームを処理する認証ハンドラがありません:私はGoogle認証例外 - スキームを処理する認証ハンドラが設定されていません:Cookies

Error Page

間違っているところクッキーはここ

がstartup.cs

app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      LoginPath = new PathString("/account/login"), 
      AuthenticationScheme = "MyCookieMiddlewareInstance", 
      AutomaticAuthenticate = true, 
      AutomaticChallenge = true, 
      AccessDeniedPath = new PathString("/Home/AccessDenied"), 
     }); 

     app.UseGoogleAuthentication(new GoogleOptions 
     { 
      AuthenticationScheme = "Google", 
      DisplayName = "Google", 
      SignInScheme = "Cookies", 
      ClientId = "ClientId ", 
      ClientSecret = "ClientSecret ", 
      Scope = { "email", "openid" }, 
      CallbackPath = "/home", 
     }); 

のための私の設定である私を提案してください。

答えて

0

あなたはAddCookieAuthentication拡張メソッド使用してASP.NETコアが提供するデフォルトCookieAuthenticationHandlerハンドラを登録することができ:

using Microsoft.AspNetCore.Authentication.Cookies; 

ます。public void ConfigureServices(IServiceCollectionサービス) { services.AddCookieAuthenticationを(); ... }

更新

認証ミドルウェアでbreaking changeがありました。 ASP.NETコアにはAddAuthentication()拡張メソッドが1つしかなく、すべてのコンフィグレーションに対応するUseXXXAuthentication拡張メソッドがスローされます。簡単な例についてSecurity repo samplesに見て:authentication-cookieセクションに

using Microsoft.AspNetCore.Authentication.Cookies; 


public void ConfigureServices(IServiceCollection services) 
{ 
    services.AddAuthentication(); 
} 

public void Configure(IApplicationBuilder app) 
{ 
    ... 
    app.UseCookieAuthentication(new CookieAuthenticationOptions 
    { 
     AutomaticAuthenticate = true 
    }); 
} 

ルックは、ドキュメントで使用可能なオプションのために

+0

AddCookieAuthenticationはIServiceCollectionオブジェクトのメソッドではありません。この名前空間が参照されていることを確認しましたが、まだこの例外が発生しています。 –

+0

@ NathanTregillus更新を確認してください – Set

関連する問題