c# - ASP.NET 使用 Twitter 按钮登录 - 如果已经通过身份验证,如何停止要求用户进行身份验证?

标签 c# asp.net twitter-oauth

我正在我的网站项目中使用 Twitterizer 库。在我们的网站中,我们使用“使用 Twitter 登录”按钮。我们遇到的问题是,在某些计算机上,它不断将用户引导至 Twitter 并要求他进行身份验证并允许应用程序进行交互。如果用户之前已经验证了我们的应用程序,我该如何阻止这种情况?

这是我用于该按钮的代码:

string callbackUrl = string.Concat(Request.Url.GetLeftPart(UriPartial.Authority), "/Callback.aspx");

        if (Request.UrlReferrer != null)
        {
            callbackUrl = string.Format("{0}?sendto={1}", callbackUrl, HttpUtility.UrlEncode(Request.UrlReferrer.AbsoluteUri));
        }
        OAuthTokenResponse requestTokenResponse = OAuthUtility.GetRequestToken(
            ConfigurationManager.AppSettings["Twitter.ConsumerKey"],
            ConfigurationManager.AppSettings["Twitter.ConsumerSecret"],
            callbackUrl);

        string authUrl = OAuthUtility.BuildAuthorizationUri(requestTokenResponse.Token,true).AbsoluteUri;
        Response.Redirect(authUrl);

通过将 authUrl 更改为以下内容解决了这个问题:

string authUrl = "https://api.twitter.com/oauth/authenticate?oauth_token=" + requestTokenResponse.Token;

最佳答案

我认为没有办法停止要求用户通过 Twitter 进行身份验证。根据之前使用 SocialAuth.NET 的经验、Twitterizer 和 OAuth 路线,我一直都经历过身份验证页面,其他人也经历过此 discussion .

更新

这篇文章应该对您有帮助:https://stackoverflow.com/a/9910051/1300806 .

我刚刚尝试使用帖子中所述的方法,并设法让我的 Twitter 实现(使用 OAuth)正常工作,这样用户就不必不断授予权限。

你每天都会学到新东西!

关于c# - ASP.NET 使用 Twitter 按钮登录 - 如果已经通过身份验证,如何停止要求用户进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12704331/

相关文章:

c# - Entity Framework 5 - 抽象类型 'X' 没有映射后代,因此无法映射

c# - 在没有存储过程的情况下从 SQL Server 表生成 C# 类

twitter - 错误代码 215 : twitter search api?

.Net Twitter OAuth 如何执行成功的 GET 请求

c# - 推特用户: "Could not authenticate with OAuth"

c# - 将 Simpleitk 图像转换为位图。系统参数异常

C#: operator '-' cannot be applied to operands of type 'string' and 'int' 错误

从 Excel 驱动的 C# NUnit 3 数据

javascript - 如何在 C# 中将 Javascript 字符串写入 StringBuilder

c# - 我的数据源包含一个值,但 EVAL 不在标签中显示该值