2017-12-07 14 views
0

私は、GoogleにSSOを行うためにIdentity2 MVC5とGoogleのログインを使用してアプリ...私が正常にログインした場合なぜこの場合GetExternalLoginInfoAsync()はnullを返しますか?

は、 このコードブロックはLOGININFO == nullのを取得し、その後、その後、ブラウザを閉じて再度ログインを作成しました

public async Task<ActionResult> ExternalLoginCallback(string returnUrl) 
     { 
      var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); 
      if (loginInfo == null) 
      { 
       return RedirectToAction("LogOut"); 
       //return RedirectToAction("Login"); 
      } 

私の最高の推測では、asp.netクッキーがセッションであるということですので、削除されたが、GoogleのOAuthトークンはまだ...どこか

これは何が起こっているのですが長引くのですか? oauthトークンをクリーンアップするにはどうすればよいですか?

私は、ログインページのPageReadyで実行し、いくつかのアプローチを試みた(つまり、ログインページヒットしたときに、すべての永続ログインをクリーンアップ)である

var user = UserManager.FindByName(User.Identity.Name); 
var AuthenticationManager = HttpContext.GetOwinContext().Authentication; 

AuthenticationManager.SignOut(); 
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); 
Session.Abandon(); 

if (user != null) 
{ 
    UserManager.UpdateSecurityStamp(user.Id); // remove the old cookie so it cant' be reused to re-log in - EWB 
} 

し、最終的に

return Redirect("https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=https://"+ Url.Action("Index", "Home", new { target = "_blank" })); //https://stackoverflow.com/questions/27515518/asp-net-identity-external-login-wont-log-out - f belihocine answer 

をgoogleからログアウトしているはずです(そして、私たちのカスタムログアウトページに行くので、本当のようです)。

しかし、私はまだ同じ動作をしています

正確には何が起こっていますか?

タイムアウトの期限が切れるまで、私は待っていれば(10分)のものは、私はアプリのクッキーや外部のクッキーを作成し、唯一のアプリケーションのクッキーを削除したため、それは、nullを返していました...通常

答えて

0

を働きます。これを呼び出す

は私が

Request.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);// https://stackoverflow.com/questions/28999318/owin-authentication-signout-doesnt-seem-to-remove-the-cookie - stralos s answer 
Request.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ExternalCookie); 
を望んでいた方法をログアウト
関連する問題