Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Owin的Twitter外部登录提供HTTP 403(禁止)_C#_Asp.net Mvc_Owin_Twitter Login - Fatal编程技术网

C# 使用Owin的Twitter外部登录提供HTTP 403(禁止)

C# 使用Owin的Twitter外部登录提供HTTP 403(禁止),c#,asp.net-mvc,owin,twitter-login,C#,Asp.net Mvc,Owin,Twitter Login,ASP.NETMVC5项目 Owin版本4.0.0.0 Startup.Auth app.UseTwitterAuthentication( consumerKey: "somekey", consumerSecret: "someSecretKey"); 异常发生在ExternalLogin方法中 响应状态代码不表示成功:403(禁止) 以下是回调URL FYI:该网站是真实的,并且运行正常,Twitter登录在几周前还可以正常工作,但现在,突然之间,由于之前的错误而开始失败 S

ASP.NETMVC5项目
Owin版本4.0.0.0

Startup.Auth

app.UseTwitterAuthentication(
  consumerKey: "somekey",
  consumerSecret: "someSecretKey");
异常发生在
ExternalLogin
方法中

响应状态代码不表示成功:403(禁止)

以下是回调URL

FYI:该网站是真实的,并且运行正常,Twitter登录在几周前还可以正常工作,但现在,突然之间,由于之前的错误而开始失败


StackTrace

[HttpRequestException: Response status code does not indicate success: 403 (Forbidden).]
   System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() +121834
   Microsoft.Owin.Security.Twitter.<ObtainRequestTokenAsync>d__23.MoveNext() +2387
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Twitter.<ApplyResponseChallengeAsync>d__12.MoveNext() +1091
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<ApplyResponseCoreAsync>d__b.MoveNext() +376
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<ApplyResponseAsync>d__8.MoveNext() +475
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<TeardownAsync>d__5.MoveNext() +215
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +968
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +768
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<RunApp>d__5.MoveNext() +197
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +768
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +768
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +768
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +768
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +768
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +768
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +768
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.AspNet.Identity.Owin.<Invoke>d__0.MoveNext() +448
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.AspNet.Identity.Owin.<Invoke>d__0.MoveNext() +448
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.AspNet.Identity.Owin.<Invoke>d__0.MoveNext() +448
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<RunApp>d__5.MoveNext() +197
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
   Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<DoFinalWork>d__2.MoveNext() +184
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
   Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +117
   System.Web.<>c__DisplayClass11_0.<InvokeEndHandler>b__0() +41
   System.Web.AsyncEventExecutionStep.InvokeEndHandler(IAsyncResult ar) +151
   System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +156
[HttpRequestException:响应状态代码不表示成功:403(禁止)。]
System.Net.Http.HttpResponseMessage.EnsureAccessStatusCode()+121834
Microsoft.Owin.Security.Twitter.d_u23.MoveNext()+2387
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Twitter.d_u12.MoveNext()+1091
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_ub.MoveNext()+376
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u8.MoveNext()+475
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u5.MoveNext()+215
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u0.MoveNext()+968
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u0.MoveNext()+768
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d_u5.MoveNext()+197
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u0.MoveNext()+768
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u0.MoveNext()+768
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u0.MoveNext()+768
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u0.MoveNext()+768
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u0.MoveNext()+768
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u0.MoveNext()+768
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Security.Infrastructure.d_u0.MoveNext()+768
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.AspNet.Identity.Owin.d_u0.MoveNext()+448
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.AspNet.Identity.Owin.d_u0.MoveNext()+448
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.AspNet.Identity.Owin.d_u0.MoveNext()+448
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d_u5.MoveNext()+197
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+60
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d_u2.MoveNext()+184
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+31
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)+117
System.Web.c_uuudisplayClass11_0.b_uuu0()+41
System.Web.AsyncEventExecutionStep.InvokeEndHandler(IAsyncResult ar)+151
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)+156

在过去一两周内,我们遇到了类似的问题,发现Twitter虽然之前没有验证回调URL,但已经开始检查它

Twitter的登录流如下所示:

  • 客户端调用您的后端
  • 后端使用回调URL、键等调用Twitter API
  • Twitter发布一个登录URL