- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
为什么在以本地主机调试和运行应用程序时可以通过 Facebook 成功登录,但在发布到 1and1.com 后却不能?
我已经在这里待了将近一个星期。我在我读过的每个论坛上都尝试过一切,但收效甚微。问题是,它在作为本地主机运行时工作正常,但在发布到我的生产站点时失败了。生产站点由 1and1.com 托管。令人困惑的是我曾经能够在生产环境中进行身份验证;但不是因为。整个项目几乎都是在 visual Studio 2017 中创建新的 MVC Web 应用程序时的默认设置。下面是整个设置:
Facebook 应用设置:
smarthomeprodealer.com
https://smarthomeprodealer.com
是
是
是
是
是
否
https://smarthomeprodealer.com/
https://smarthomeprodealer.com/signin-facebook
https://localhost:44300/
https://localhost:44300/signin-facebook
Startup.Auth.cs
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseFacebookAuthentication(new FacebookAuthenticationOptions
{
AppId = "*************",
AppSecret = "*********************************",
SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
Provider = new FacebookAuthenticationProvider
{
OnAuthenticated = context =>
{
context.Identity.AddClaim(new Claim("FacebookAccessToken", context.AccessToken));
foreach (var claim in context.User)
{
var claimType = $"urn:facebook:{claim.Key}";
var claimValue = claim.Value.ToString();
if (!context.Identity.HasClaim(claimType, claimValue))
context.Identity.AddClaim(new Claim(claimType, claimValue, "XmlSchemaString", "Facebook"));
}
return Task.FromResult(0);
}
}
});
}
}
AccountController.cs
[AllowAnonymous]
public async Task<ActionResult> ExternalLoginCallback(string returnUrl, string error)
{
if (error != null)
{
return this.View("Error");
}
var loginInfo = await this.AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
this.ModelState.AddModelError("", "Failed to get external login info.");
return this.RedirectToAction("Login");
}
// Sign in the user with this external login provider if the user already has a login
var result = await this.SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
switch (result)
{
case SignInStatus.Success:
return this.RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return this.View("Lockout");
case SignInStatus.RequiresVerification:
return this.RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
case SignInStatus.Failure:
default:
// If the user does not have an account, then prompt the user to create an account
this.ViewBag.ReturnUrl = returnUrl;
this.ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
ExternalLoginConfirmationViewModel viewModel = null;
if (string.Equals(loginInfo.Login.LoginProvider, "facebook", StringComparison.CurrentCultureIgnoreCase))
{
var identity = this.AuthenticationManager.GetExternalIdentity(DefaultAuthenticationTypes.ExternalCookie);
var email = loginInfo.Email;
var firstName = identity.FindFirstValue("urn:facebook:first_name");
var lastName = identity.FindFirstValue("urn:facebook:last_name");
viewModel = new ExternalLoginConfirmationViewModel
{
Email = email,
FirstName = firstName,
LastName = lastName
};
}
if (viewModel == null)
{
viewModel = new ExternalLoginConfirmationViewModel { Email = loginInfo.Email };
}
return this.View("ExternalLoginConfirmation", viewModel);
}
}
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net472" />
<package id="bootstrap" version="3.3.7" targetFramework="net472" />
<package id="EntityFramework" version="6.2.0" targetFramework="net472" />
<package id="Facebook" version="7.0.6" targetFramework="net472" />
<package id="jQuery" version="3.3.1" targetFramework="net472" />
<package id="jQuery.MaskedInput" version="1.4.1.0" targetFramework="net472" />
<package id="jQuery.Validation" version="1.17.0" targetFramework="net472" />
<package id="Microsoft.ApplicationInsights.Agent.Intercept" version="2.4.0" targetFramework="net472" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.2" targetFramework="net472" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.2" targetFramework="net472" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.2" targetFramework="net472" />
<package id="Microsoft.AspNet.Mvc" version="5.2.4" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.4" targetFramework="net472" />
<package id="Microsoft.AspNet.TelemetryCorrelation" version="1.0.0" targetFramework="net472" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net472" />
<package id="Microsoft.AspNet.WebPages" version="3.2.4" targetFramework="net472" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net472" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.4" targetFramework="net472" />
<package id="Microsoft.Owin" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Security" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Security.Cookies" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Security.Facebook" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Security.Google" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Security.MicrosoftAccount" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Security.OAuth" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Security.Twitter" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net472" />
<package id="Modernizr" version="2.8.3" targetFramework="net472" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net472" />
<package id="Owin" version="1.0" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="4.4.1" targetFramework="net472" />
<package id="WebGrease" version="1.6.0" targetFramework="net472" />
</packages>
我成功打开了 Facebook 的身份验证窗口,但在单击 continue
后,我收到以下网络调用:
一般
Request URL: https://smarthomeprodealer.com/signin-facebook?code=AQDBJtnrFRAOWXlsP-XwPpGYmOck3299lBcir6-W-1pK_jZDkKELCflt91yJ_RJQ5hChBUBgvxa6X-ZPxuCDiojdQOMiSOlxAdS6-3IUmGqCwfEqgROmnZF2WD3xsdZJNgRctbsR5-DPWcNUunB4Nmi0Z2fLPb6Cz7_kozK3MRRSuEiKDwfStUHeP_Hb07IZYXYQcDzq5XuR8FB-ZUDn4LLGoMgVQQ-O96FIvt7d_Yrm1_-THCk94HBdBRWlUyVXWBTFCssBZt7h5rE2lxqBnNREmEHXZgYaEDPDIAXA7Evp_M7tUu-BnkjJp1KojzXtcrcvCzV2oFflFy33gZr6kWvo&state=VctNDgrl9b6gQpcRUucyMLSWedxDOr6yhbmvlGRD37mWbVgAuW2p1nFbBkzJzIMjaXF65YKpKzEDiTYrSJDpVRnZIRyjiUnL-JW3Y6-evmerqysAezMENlneW3i3bvkH4f6BAvAMJw0C7SC6B2E2zlcGqvYJZvp0hlFqJbI1KhgMlozrChZcEFlYU0_leEXAp7JiwokC0ZloyRN9o3YA4siHolsHIR1tcOKnAoHSYaU
Request Method: GET
Status Code: 302
Remote Address: 74.208.236.203:443
Referrer Policy: origin-when-cross-origin
响应头
content-length: 0
date: Fri, 24 Aug 2018 23:52:41 GMT
location: /Account/ExternalLoginCallback?error=access_denied
server: Microsoft-IIS/10.0
set-cookie: .AspNet.Correlation.Facebook=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
status: 302
x-powered-by: ASP.NET
请求 header
:authority: smarthomeprodealer.com
:method: GET
:path: /signin-facebook?code=AQDBJtnrFRAOWXlsP-XwPpGYmOck3299lBcir6-W-1pK_jZDkKELCflt91yJ_RJQ5hChBUBgvxa6X-ZPxuCDiojdQOMiSOlxAdS6-3IUmGqCwfEqgROmnZF2WD3xsdZJNgRctbsR5-DPWcNUunB4Nmi0Z2fLPb6Cz7_kozK3MRRSuEiKDwfStUHeP_Hb07IZYXYQcDzq5XuR8FB-ZUDn4LLGoMgVQQ-O96FIvt7d_Yrm1_-THCk94HBdBRWlUyVXWBTFCssBZt7h5rE2lxqBnNREmEHXZgYaEDPDIAXA7Evp_M7tUu-BnkjJp1KojzXtcrcvCzV2oFflFy33gZr6kWvo&state=VctNDgrl9b6gQpcRUucyMLSWedxDOr6yhbmvlGRD37mWbVgAuW2p1nFbBkzJzIMjaXF65YKpKzEDiTYrSJDpVRnZIRyjiUnL-JW3Y6-evmerqysAezMENlneW3i3bvkH4f6BAvAMJw0C7SC6B2E2zlcGqvYJZvp0hlFqJbI1KhgMlozrChZcEFlYU0_leEXAp7JiwokC0ZloyRN9o3YA4siHolsHIR1tcOKnAoHSYaU
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: max-age=0
cookie: __RequestVerificationToken=S5Juj1hBkXIjmD-grTT7GznV6FrUMuyGCBmI5JoL9wXGoo3l9PKqscj54umCFGOSuK5pmx6Kjv8ap9QJ8q6ixNF2M9syQkq-iwDchS5m1u81; ASP.NET_SessionId=xaj1bb3qc5mzuefk3imxhhnl; .AspNet.Correlation.Facebook=pfQHMd0GIkxHeDwrLwGzcUdfmCUPPS2tR9G_WFPeueE
dnt: 1
referer: https://www.facebook.com/
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
为什么在以本地主机调试和运行应用程序时可以通过 Facebook 成功登录,但在发布到 1and1.com 后却不能?
最佳答案
我知道这已经有一段时间了,但在与托管团队进行故障排除后,他们建议我将其放入 web.cofig 中并且它起作用了!
<system.net> <defaultProxy> <proxy usesystemdefault = "false" bypassonlocal="false" proxyaddress="http://ntproxy.1and1.com:3128" /> </defaultProxy> </system.net>
关于facebook - MVC5 Facebook 身份验证-帐户/ExternalLoginCallback?error=access_denied#_=_,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52013039/
过去几天我一直试图解决这个问题,但我做不到。我正在尝试生成 _ _ _ 形式的随机数。 _ _ _ _ 小数点前 3 位,然后是 4 位小数。 非常感谢任何帮助。谢谢, 院长 最佳答案 您发布的代码有
我的方法有问题。我需要从主类调用的方法的输出打印我: 需要这个输出:_ _ _ _ _ 我知道我可以将 System 的静态方法放入循环中,但这不是我想要的解决方案。我需要它来打印主类中方法的输出。
我正在学习 Scala,有一个非常基本的问题。考虑以下两个使用占位符语法的表达式 - // Syntax A val fnA = (_: Int, _: Int) => _ / _ // Synta
我正在使用图书馆 URLEmbeddedView 它在其库中定义了以下代码: func addConstraints(with view: UIView, center: CGPoint, multi
我一直在许多受人尊敬的文档中看到这个相当令人尴尬的事情:_|_ 或 (_|_) 找不到它的定义(Google 不能很好地处理符号)。那到底是什么呢? 最佳答案 来自 here :- Bottom Th
,_,( ){ ,_,| ,_,&};,_, 不知道是什么意思... 看起来像一个 bash 命令,但它可能是 s bash shell 指令或其他东西如果有人可以帮助理解这一点,我们将不胜感激。当我
所以我正在尝试构建一个函数,它接受一个元组列表并找到具有最大第二个元素的元组。但是我遇到了模式匹配错误。 这是我的代码。 resultTuple :: [((Int,Int),Int)] ->
我在 try Flow 编辑器中重现了我的情况,可以访问 here . 以下是链接发生问题时的代码: /* @flow */ type PayloadType = 1 | 2 | 3; type Tr
我在plfa读到这样一段代码。 import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; s
这个问题在这里已经有了答案: Swift 3.0: compiler error when calling global func min(T,T) in Array or Dictionary e
是否有理由使用一个而不是另一个?似乎 _.some 和 _.map 更易于使用或适用于更多情况(根据我非常有限的经验),但从阅读它来看,它们听起来好像应该做同样的事情。我敢肯定还有其他这样的例子,我很
在 Xcode 7 Beta 中开始使用 Swift 2 后,出现错误 cannot invoke。是什么导致了这个问题? 我试图通过以下两个问题找出我的问题,但我仍然收到错误:Question 1
所以我玩了一会儿,试图写一些关于存在和变化的东西,我遇到了这段有趣的代码。 final case class Box[+T](val value: T) { def >>=[U](f: T =>
Here is the screenshot for the error. 遵循本教程 https://developers.google.com/places/ios-api/start 在本教程中
我正在为许多标准的 Underscore.js 函数重写底层代码,以提高我的 JavaScript 技能,但我有点受困于 _.every/ _.全部。似乎在库本身中,_.every/_.all 函数仅
我在 shell 脚本中多次看到他们在 if 比较中使用 "_",如下所示: if [ "_$str" = "_" ]; then ....; fi 上面的代码通过比较 if [ "_$str"= "
我正在尝试快速过滤字典: var data: [String: String] = [:] data = data.filter { $0.1 == "Test" } 上面的过滤器代码在 Swift
我在 Entity Framework 核心映射方面遇到了问题。我收到此异常“不支持从‘付款’到‘购买。付款’的关系,因为拥有的实体类型‘购买’不能位于非所有权关系的主要方面。”在调试此功能的测试时。
我正在尝试模拟groovy.sql.Sql调用(查询,params [],闭包)类。 下面是我正在尝试在DatabaseService类文件中的方法。 public void getUsers(Lis
在阅读 dart 代码时,我经常看到一些仅使用下划线 _ 参数调用的函数。这让我困扰了一段时间,由于 flutter 改进了它的分析消息,我有了一些线索......但我觉得我并没有真正理解这个概念:-
我是一名优秀的程序员,十分优秀!