【发布时间】:2014-03-03 23:27:54
【问题描述】:
我一直在使用 Linq2Twitter (v. 2),使用 Search API 和
我想切换到 Stream API。我更新到 v. 3 但从那以后我不再设法进行身份验证。我不认为 Stream API 或版本可能是问题,因为我试图回到以前的版本,以前的身份验证方法,它也不再起作用了。我收到了401 : bad authentication data.
所以,这是我当前的代码:
var auth = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore()
{
ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"],
OAuthToken = ConfigurationManager.AppSettings["twitterOAuthToken"],
AccessToken = ConfigurationManager.AppSettings["twitterAccessToken"]
}
};
TwitterContext _twitterCtx = new TwitterContext(auth);
try
{
var verifyResponse =
await
(from acct in _twitterCtx.Account
where acct.Type == AccountType.VerifyCredentials
select acct)
.SingleOrDefaultAsync();
if (verifyResponse != null && verifyResponse.User != null)
{
User user = verifyResponse.User;
Console.WriteLine(
"Credentials are good for {0}.",
user.ScreenNameResponse);
}
}
catch (TwitterQueryException tqe)
{
Console.WriteLine(tqe.Message);
}
当然,我检查了几次凭据,将它们打印出来。 我也尝试过 ApplicationOnlyAuthorizer、v.2、v.3,它没有任何改变。 最让我害怕的是,以前有效的(v2 + ApplicationOnly + Search API)也不起作用。
通过我的研究,我听说过由不同步的时间戳或类似问题引起的问题。但我不明白我该如何改变这一点。 该程序不在服务器上,它在本地存储。
感谢您的阅读。
【问题讨论】:
标签: c# authentication twitter linq-to-twitter