【问题标题】:Tweetinvi 4.0.1 AuthFlow.InitAuthentications returns nullTweetinvi 4.0.1 AuthFlow.InitAuthentications 返回 null
【发布时间】:2019-12-25 03:24:56
【问题描述】:

C# 实现。密钥已验证。 Twitter 应用配置中的回调 url。

使用版本 4.0.1 以及 JsonLanguageConvertFix

private IAuthenticationContext _authenticationContext;

string TWcallbackURL = href_core_twitter + "?twcc=" + vCode;
var appCreds = new ConsumerCredentials(TWConsumerKey, TWConsumerKey_secret);
_authenticationContext = AuthFlow.InitAuthentication(appCreds, TWcallbackURL);
if(_authenticationContext == null)
                    {
                        _url = "NO URL";
                        _status = "ERROR";
                        _authKey = "";
                        _authSecret = "";
                    }
                    else
                    {
                        _url = _authenticationContext.AuthorizationURL;
                        _authKey = _authenticationContext.Token.AuthorizationKey;
                        _authSecret = _authenticationContext.Token.AuthorizationSecret;
                        _status = "OK";
                    }

_authenticationContext 始终为空,无论我尝试过什么。大约一周前,这段代码可以正常工作。

【问题讨论】:

    标签: c# tweetinvi


    【解决方案1】:

    问题在于安全协议。需要以下内容:

                        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
                                                            | SecurityProtocolType.Tls11
                                                            | SecurityProtocolType.Tls12
                                                            | SecurityProtocolType.Ssl3;
    

    现在一切正常。

    【讨论】:

    • 非常感谢我的朋友!我一直在为这个问题苦苦挣扎!
    • 看起来代码工作了一段时间,几分钟后又出错了,即使添加了这段代码也是如此。您的应用程序是否一直运行良好?
    猜你喜欢
    • 2020-12-13
    • 2017-05-21
    • 1970-01-01
    • 2020-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-21
    • 2021-03-11
    相关资源
    最近更新 更多