Facebook,谷歌的OAuth有时无法在Azure上 [英] Facebook, Google OAuth fails sometimes on Azure

查看:201
本文介绍了Facebook,谷歌的OAuth有时无法在Azure上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Asp.Net MVC的OAuth登录与Facebook和谷歌和奇怪的事情,在某些时期,它亘古不变的工作

I am using Asp.Net MVC OAuth login with facebook and google and strange thing that at some period it doesnot work

var externalIdentity =
                HttpContext.GetOwinContext()
                    .Authentication.GetExternalIdentityAsync(DefaultAuthenticationTypes.ExternalCookie);

var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
   return RedirectToAction("Login");
}

似乎在这里不能得到用户信息,并重定向到登录页面。我无法弄清楚,为什么还是什么可能会导致。
我也有两个插槽,测试和生产。

Seems here it cant get user info and redirect to login page. I cant figure out why or what can cause that. I also have two slots beta and production.

所以任何建议或也许有人已经拥有了,发现路该怎么解决呢?

So any suggestion or maybe somebody already have that and found way how to fix that?

推荐答案

几个星期后,我终于解决了我的问题。它真的有些奇怪,可能的问题是,因为天蓝色的,因为我的工作落实上VMvare之前6月份。

Finally after few weeks i solve my problem. Its really something strange and probably issue is because of azure because my implementation works on VMvare before for 6 month.

在的AccountController有法

in AccountController there is method

public ActionResult ExternalLogin(string provider, string returnUrl)

添加有

Session.RemoveAll();

PS /时的OAuth失败我只是简单地重新启动Web应用程序,它开始工作时,首先我看到了这个建议,我不知道它如何可以帮助,但随后下一次。顺便说一句即使是现在我不明白是怎么回事,与会话,但它的工作原理。

PS/ Firstly when I have seen this recommendation I did not understood how it can help but then next time when OAuth fails i just simply restarted WebApp and it starts working. By the way even now i dont understand what is going on with session but it works.

这篇关于Facebook,谷歌的OAuth有时无法在Azure上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆