Asp.Net MVC 5 Owin Twitter Auth throwing 401 Exception

我已经使用Owin中间件设置了OAuth身份验证,它基于在使用“个人帐户”身份验证启动新的Web项目时创建的认项目。

我调整了一点,但Facebook和谷歌工作很好,但是,当我点击“twitter”按钮发出挑战,它抛出一个500 http异常与错误消息:

Response status code does not indicate success: 401 (Unauthorized).

这只是推出了Twitter。这里是我的auth配置:

// Just a configuration section that reads from the web.config
var configuration = new OwinCookieConfigurationSection("owinCookieConfiguration");
app.UseCookieAuthentication(GetCookieAuthenticationoptions(configuration));
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

app.UseTwitterauthentication(
    consumerKey: "XXX",consumerSecret: "XXX"
);

app.UseFacebookAuthentication(
    appId: "XXX",appSecret: "XXX"
);

app.UseGoogleAuthentication();

这肯定是一个500错误,而不是一个401错误,它表明,我已经确认它从来没有使它通过原始的帖子挑战到Twitter。堆栈跟踪显示显示Twitter未从ObtainRequestToken调用返回成功代码

有任何想法吗?

解决方法

你需要进入Twitter Dev应用程序并添加一个网站地址。我知道它似乎愚蠢,但这将解决你的问题。

> https://apps.twitter.com/
>转到设置选项卡
>设置任何网站的CallBack URL。即使它不是真实的。

这应该解决你的问题。

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....