C# Linq2Twitter-401:错误的身份验证数据
我一直在使用Linq2Twitter(第2节),使用搜索API和 我想切换到流API。我更新到v。3但从那以后,我再也无法进行身份验证了。我不认为流API或版本是问题所在,因为我已经尝试返回到以前的版本,以前的身份验证方法,它也不再工作。我得到了一个C# Linq2Twitter-401:错误的身份验证数据,c#,authentication,twitter,linq-to-twitter,C#,Authentication,Twitter,Linq To Twitter,我一直在使用Linq2Twitter(第2节),使用搜索API和 我想切换到流API。我更新到v。3但从那以后,我再也无法进行身份验证了。我不认为流API或版本是问题所在,因为我已经尝试返回到以前的版本,以前的身份验证方法,它也不再工作。我得到了一个401:错误的身份验证数据。 这是我目前的代码: var auth = new SingleUserAuthorizer { CredentialStore = new SingleUserI
401:错误的身份验证数据。
这是我目前的代码:
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,第2版,第3版,它没有改变任何东西。
最让我害怕的是,以前的工作方式(v2+ApplicationOnly+SearchAPI)也不起作用
通过我的研究,我听说了一个由不同步的时间戳或类似的东西引起的问题。但我不明白我怎么能改变这一点。
程序不在服务器上,而是本地存储的
感谢阅读。以下是如何在v3.0中使用SingleUserAuthorizer:
var auth = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore
{
ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"],
AccessToken = ConfigurationManager.AppSettings["accessToken"],
AccessTokenSecret = ConfigurationManager.AppSettings["accessTokenSecret"]
}
};
请注意,我正在设置AccessToken和AccessToken secret。我还有一个常见问题解答,其中包含解决401个问题的建议:
以下是如何在v3.0中使用SingleUserAuthorizer:
var auth = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore
{
ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"],
AccessToken = ConfigurationManager.AppSettings["accessToken"],
AccessTokenSecret = ConfigurationManager.AppSettings["accessTokenSecret"]
}
};
请注意,我正在设置AccessToken和AccessToken secret。我还有一个常见问题解答,其中包含解决401个问题的建议:
以下是如何在v3.0中使用SingleUserAuthorizer:
var auth = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore
{
ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"],
AccessToken = ConfigurationManager.AppSettings["accessToken"],
AccessTokenSecret = ConfigurationManager.AppSettings["accessTokenSecret"]
}
};
请注意,我正在设置AccessToken和AccessToken secret。我还有一个常见问题解答,其中包含解决401个问题的建议:
以下是如何在v3.0中使用SingleUserAuthorizer:
var auth = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore
{
ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"],
AccessToken = ConfigurationManager.AppSettings["accessToken"],
AccessTokenSecret = ConfigurationManager.AppSettings["accessTokenSecret"]
}
};
请注意,我正在设置AccessToken和AccessToken secret。我还有一个常见问题解答,其中包含解决401个问题的建议: