/// <summary> /// Verifies the authorization results for the specified request identifier and the code of the authorization, and removes the request from memory. /// </summary> /// <param name="requestId">Request identifier.</param> /// <param name="code">The authorization code received from the provider server.</param> /// <returns> /// <para>Returns the verification results.</para> /// </returns> /// <remarks> /// <para>This method is intended for internal use. It is recommended to use the overload <see cref="VerifyAuthorization()"/> or <see cref="VerifyAuthorization(string)"/>.</para> /// </remarks> public static AuthorizationResult VerifyAuthorizationAndRemoveRequest(string requestId, string code) { var result = OAuthWeb.VerifyAuthorization(requestId, code); OAuthManager.RemoveRequest(requestId); return(result); }
/// <summary> /// The method is called when the interval elapsed. /// </summary> /// <param name="sender">Instance of the object that raised the event.</param> /// <param name="e">The event data.</param> private static void Timer_Elapsed(object sender, EventArgs e) { if (_Requests.Count <= 0) { // no active requests, stop the time _Timer.Stop(); return; } // lifetime request - 20 minutes // remove old requests var now = DateTime.Now; var toRemove = _Requests.Where(itm2 => now.Subtract(itm2.Value.DateCreated).TotalMinutes >= 20).ToList(); foreach (var itm in toRemove) { if (_Requests.ContainsKey(itm.Key)) { OAuthManager.RemoveRequest(itm.Key); } } // change the status of the timer _Timer.Enabled = (_Requests.Count > 0); }