Dotnetopenauth 工作twitter登录变成401

Dotnetopenauth 工作twitter登录变成401,dotnetopenauth,Dotnetopenauth,多年来,我一直在我的网站上使用twitter登录。我随机决定今天测试它,结果发现它不起作用 我正在使用dotnetopenauth 3.4.7.11121。我的web配置中有twitterConsumerKey和TwitterConsumerCret。关于首先在哪里进行故障排除的想法 错误是“远程服务器返回错误:(401)未经授权。” 我的注意事项: public static OutgoingWebResponse StartSignInWithTwitter(bool forceNewLog

多年来,我一直在我的网站上使用twitter登录。我随机决定今天测试它,结果发现它不起作用

我正在使用dotnetopenauth 3.4.7.11121。我的web配置中有twitterConsumerKey和TwitterConsumerCret。关于首先在哪里进行故障排除的想法

错误是“远程服务器返回错误:(401)未经授权。”

我的注意事项:

public static OutgoingWebResponse StartSignInWithTwitter(bool forceNewLogin)
    {
        var redirectParameters = new Dictionary<string, string>();
        if (forceNewLogin)
        {
            redirectParameters["force_login"] = "true";
        }
        Uri callback = MessagingUtilities.GetRequestUrlFromContext().StripQueryArgumentsWithPrefix("oauth_");
        var request = TwitterSignIn.PrepareRequestUserAuthorization(callback, null, redirectParameters);
        return TwitterSignIn.Channel.PrepareResponse(request);
    }
更新
我使用了fiddler,发现dotnetopenauth从http重定向到https时没有转发身份验证。

我发现了我的问题。Twitter似乎已经开始强制使用https,重定向也停止了。我更新了我的twitter消费者,将其从http更改为https。我的消费者是从样品中提取的

/// <summary>
        /// The description of Twitter's OAuth protocol URIs for use with actually reading/writing
        /// a user's private Twitter data.
        /// </summary>
        public static readonly ServiceProviderDescription ServiceDescription = new ServiceProviderDescription
        {
            RequestTokenEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/request_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/authorize", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            AccessTokenEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/access_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() },
        };

        /// <summary>
        /// The description of Twitter's OAuth protocol URIs for use with their "Sign in with Twitter" feature.
        /// </summary>
        public static readonly ServiceProviderDescription SignInWithTwitterServiceDescription = new ServiceProviderDescription
        {
            RequestTokenEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/request_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/authenticate", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            AccessTokenEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/access_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() },
        };
//
///用于实际读/写的Twitter OAuth协议URI的描述
///用户的私有Twitter数据。
/// 
公共静态只读ServiceProviderDescription ServiceDescription=新ServiceProviderDescription
{
RequestTokenEndpoint=新消息ReceivingEndpoint(“https://twitter.com/oauth/request_token,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
UserAuthorizationEndpoint=新消息ReceivingEndpoint(“https://twitter.com/oauth/authorize,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
AccessTokenEndpoint=新的MessageReceivingEndpoint(“https://twitter.com/oauth/access_token,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
TamperProtectionElements=new-ITamperProtectionChannelBindingElement[]{new-HmacSha1SigningBindingElement()},
};
/// 
///Twitter的OAuth协议URI的描述,用于“使用Twitter登录”功能。
/// 
public static readonly ServiceProviderDescription signiWithTwitterServiceDescription=新ServiceProviderDescription
{
RequestTokenEndpoint=新消息ReceivingEndpoint(“https://twitter.com/oauth/request_token,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
UserAuthorizationEndpoint=新消息ReceivingEndpoint(“https://twitter.com/oauth/authenticate,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
AccessTokenEndpoint=新的MessageReceivingEndpoint(“https://twitter.com/oauth/access_token,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
TamperProtectionElements=new-ITamperProtectionChannelBindingElement[]{new-HmacSha1SigningBindingElement()},
};

半相关:我的旧时间线URL“”在某个时候更改为,破坏了我应用程序的另一个功能。

我发现了我的问题。Twitter似乎已经开始强制使用https,重定向也停止了。我更新了我的twitter消费者,将其从http更改为https。我的消费者是从样品中提取的

/// <summary>
        /// The description of Twitter's OAuth protocol URIs for use with actually reading/writing
        /// a user's private Twitter data.
        /// </summary>
        public static readonly ServiceProviderDescription ServiceDescription = new ServiceProviderDescription
        {
            RequestTokenEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/request_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/authorize", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            AccessTokenEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/access_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() },
        };

        /// <summary>
        /// The description of Twitter's OAuth protocol URIs for use with their "Sign in with Twitter" feature.
        /// </summary>
        public static readonly ServiceProviderDescription SignInWithTwitterServiceDescription = new ServiceProviderDescription
        {
            RequestTokenEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/request_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/authenticate", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            AccessTokenEndpoint = new MessageReceivingEndpoint("https://twitter.com/oauth/access_token", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
            TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() },
        };
//
///用于实际读/写的Twitter OAuth协议URI的描述
///用户的私有Twitter数据。
/// 
公共静态只读ServiceProviderDescription ServiceDescription=新ServiceProviderDescription
{
RequestTokenEndpoint=新消息ReceivingEndpoint(“https://twitter.com/oauth/request_token,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
UserAuthorizationEndpoint=新消息ReceivingEndpoint(“https://twitter.com/oauth/authorize,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
AccessTokenEndpoint=新的MessageReceivingEndpoint(“https://twitter.com/oauth/access_token,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
TamperProtectionElements=new-ITamperProtectionChannelBindingElement[]{new-HmacSha1SigningBindingElement()},
};
/// 
///Twitter的OAuth协议URI的描述,用于“使用Twitter登录”功能。
/// 
public static readonly ServiceProviderDescription signiWithTwitterServiceDescription=新ServiceProviderDescription
{
RequestTokenEndpoint=新消息ReceivingEndpoint(“https://twitter.com/oauth/request_token,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
UserAuthorizationEndpoint=新消息ReceivingEndpoint(“https://twitter.com/oauth/authenticate,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
AccessTokenEndpoint=新的MessageReceivingEndpoint(“https://twitter.com/oauth/access_token,HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
TamperProtectionElements=new-ITamperProtectionChannelBindingElement[]{new-HmacSha1SigningBindingElement()},
};

半相关:我的旧时间线URL“”在某个时候更改为“”,破坏了我应用程序的另一个功能。

我知道这是旧的,但感谢您提交此解决方案!没问题。我也不应该说,由于API的变化,这两个链接的时间线不再可用。我知道这是旧的,但感谢您提交此解决方案!没问题。我也不应该说,由于API的变化,任何一个链接的时间线都不再可用。