Tweetings Janetter などの一部の Twitter アプリを使用する際に、一度認証して認証ピンコードを入力します。それ以来、少なくとも 3 週間以上は再度認証する必要はありませんでした。
Spring.Net Social Twitter example ConsoleQuickStart などの .net API を使用する場合、行をスキップします。
Process.Start(authenticateUrl);
また、以前のアプリ ランタイムからコードを入力しても機能せず、例外がスローされます
一方、つぶやきなどの他の Twitter アプリをシャットダウンする場合、再認証は必要ありません !!
トークンを再利用する方法と、そのような再利用のための適切な動作に関する一般的なルールに関するヘルプはありますか?
ありがとう
アップデート -
コードをこれに変更した後、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: