在使用一些 twitter 应用程序时,例如 Tweetings Janetter 等。您验证一次并输入您的验证密码,从那时起我不必再次验证至少 3 周以上
在使用 Spring.Net Social Twitter 示例 ConsoleQuickStart 等 .net api 时,跳过该行
Process.Start(authenticateUrl);
并且从以前的应用程序运行时输入代码不起作用并抛出异常
而关闭其他推特应用程序(例如推文)不需要重新验证!
关于如何重用令牌和关于这种重用的良好行为的一般规则的任何帮助?
谢谢
更新 -
现在在将代码更改为此后获得 HTTP 401 Unauthorized -
if ( ! haveOAuthAndPin )
{
var oauthToken = twitterServiceProvider.OAuthOperations.FetchRequestTokenAsync("oob", null).Result;
string authenticateUrl = twitterServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, null);
Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
Process.Start(authenticateUrl);
Console.WriteLine("Enter PIN Code from Twitter authorization page:");
pinCode = Console.ReadLine();
StoreAuthTokenAndPin(oAuthToken, pinCode);
}
else
{
var oAuthToken = new oAuthToken(storedValue, storedSecret)
pinCode = storedPinCode ;
}
完整的错误堆栈是 -
System.AggregateException was unhandled
HResult=-2146233088
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.AggregateException.Handle(Func`2 predicate)
at Spring.ConsoleQuickStart.Program.Main(String[] args) in C:\downloads\_source-code\Spring.net\Spring.Social.Twitter-2.0.0-M1\examples\Spring.ConsoleQuickStart\src\Spring.ConsoleQuickStart\Program.cs:line 168
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.AggregateException
HResult=-2146233088
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Spring.Social.OAuth1.OAuth1Template.<ExchangeForAccessTokenAsync>b__1(Task`1 task) in f:\bamboo-home\xml-data\build-dir\SPRNETSOCIAL-RELEASE-JOB1\src\Spring.Social.Core\Social\OAuth1\OAuth1Template.cs:line 233
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
InnerException: Spring.Rest.Client.HttpClientErrorException
HResult=-2146233088
Message=POST request for 'https://api.twitter.com/oauth/access_token' resulted in 401 - Unauthorized (Unauthorized).
Source=Spring.Rest
StackTrace:
at Spring.Rest.Client.Support.DefaultResponseErrorHandler.HandleError(Uri requestUri, HttpMethod requestMethod, HttpResponseMessage`1 response) in f:\bamboo-home\xml-data\build-dir\SPRNETREST-RELEASE-JOB1\src\Spring.Rest\Rest\Client\Support\DefaultResponseErrorHandler.cs:line 121
at Spring.Rest.Client.Support.DefaultResponseErrorHandler.HandleError(Uri requestUri, HttpMethod requestMethod, IClientHttpResponse response) in f:\bamboo-home\xml-data\build-dir\SPRNETREST-RELEASE-JOB1\src\Spring.Rest\Rest\Client\Support\DefaultResponseErrorHandler.cs:line 86
at Spring.Rest.Client.RestTemplate.HandleResponseError(Uri uri, HttpMethod method, IClientHttpResponse response, IResponseErrorHandler errorHandler) in f:\bamboo-home\xml-data\build-dir\SPRNETREST-RELEASE-JOB1\src\Spring.Rest\Rest\Client\RestTemplate.cs:line 2959
at Spring.Rest.Client.RestTemplate.ResponseReceivedCallback[T](ClientHttpRequestCompletedEventArgs responseReceived) in f:\bamboo-home\xml-data\build-dir\SPRNETREST-RELEASE-JOB1\src\Spring.Rest\Rest\Client\RestTemplate.cs:line 2777
InnerException: