public void Attempt_to_refresh_token_multiple_times_despite_exception() { // Arrange var clientId = "abc123"; var clientSecret = "xyz789"; var authorizationCode = "INVALID_AUTH_CODE"; var connectionInfo = new OAuthConnectionInfo(clientId, clientSecret, authorizationCode, null); var apiResponse = "{ \"reason\":\"Invalid authorization code " + authorizationCode + "\",\"error\":\"invalid_request\"}"; var mockHttp = new MockHttpMessageHandler(); mockHttp .When(HttpMethod.Post, $"https://api.zoom.us/oauth/token?grant_type=authorization_code&code={authorizationCode}") .Respond(HttpStatusCode.BadRequest, "application/json", apiResponse); var handler = new OAuthTokenHandler(connectionInfo, mockHttp.ToHttpClient(), null); // Act Should.Throw <ZoomException>(() => handler.RefreshTokenIfNecessary(true)); Should.Throw <ZoomException>(() => handler.RefreshTokenIfNecessary(true)); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); }
public async Task <PostgresExternalUserDecrypted> DecryptTokensAsync(OAuthTokenHandler tokenHandler) { if (this.Token != null) { this.Token = await tokenHandler.DecryptAsync(this.Token); } if (this.RefreshToken != null) { this.RefreshToken = await tokenHandler.DecryptAsync(this.RefreshToken); } return(this); }
private ZoomClient(IConnectionInfo connectionInfo, HttpClient httpClient, bool disposeClient, ZoomClientOptions options, ILogger logger = null) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient; var options1 = options ?? GetDefaultOptions(); _fluentClient = new FluentClient(new Uri(ZoomV2BaseUri), httpClient) .SetUserAgent($"ZoomNet/{Version} (+https://github.com/Jericho/ZoomNet)"); _fluentClient.Filters.Remove <DefaultErrorFilter>(); switch (connectionInfo) { // Order is important: the token handler (either JWT or OAuth) must be first, followed by DiagnosticHandler and then by ErrorHandler. case JwtConnectionInfo jwtConnectionInfo: { var tokenHandler = new JwtTokenHandler(jwtConnectionInfo); _fluentClient.Filters.Add(tokenHandler); _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler)); break; } case OAuthConnectionInfo oauthConnectionInfo: { var tokenHandler = new OAuthTokenHandler(oauthConnectionInfo, httpClient); _fluentClient.Filters.Add(tokenHandler); _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler)); break; } default: throw new ZoomException($"{connectionInfo.GetType()} is an unknown connection type", null, null); } // The list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(options1.LogLevelSuccessfulCalls, options1.LogLevelFailedCalls)); _fluentClient.Filters.Add(new ZoomErrorHandler()); Meetings = new Meetings(_fluentClient); PastMeetings = new PastMeetings(_fluentClient); PastWebinars = new PastWebinars(_fluentClient); Users = new Users(_fluentClient); Webinars = new Webinars(_fluentClient); }
private ZoomClient(IConnectionInfo connectionInfo, HttpClient httpClient, bool disposeClient, ZoomClientOptions options, ILogger logger = null) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); _options = options ?? GetDefaultOptions(); _logger = logger ?? NullLogger.Instance; _fluentClient = new FluentClient(new Uri(ZOOM_V2_BASE_URI), httpClient) .SetUserAgent($"ZoomNet/{Version} (+https://github.com/Jericho/ZoomNet)"); _fluentClient.Filters.Remove <DefaultErrorFilter>(); // Order is important: the token handler (either JWT or OAuth) must be first, followed by DiagnosticHandler and then by ErrorHandler. if (connectionInfo is JwtConnectionInfo jwtConnectionInfo) { var tokenHandler = new JwtTokenHandler(jwtConnectionInfo); _fluentClient.Filters.Add(tokenHandler); _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler)); } else if (connectionInfo is OAuthConnectionInfo oauthConnectionInfo) { var tokenHandler = new OAuthTokenHandler(oauthConnectionInfo, httpClient); _fluentClient.Filters.Add(tokenHandler); _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler)); } else { throw new ZoomException($"{connectionInfo.GetType()} is an unknown connection type", null, null, null, null); } // The list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls, _logger)); _fluentClient.Filters.Add(new ZoomErrorHandler()); Accounts = new Accounts(_fluentClient); Chat = new Chat(_fluentClient); CloudRecordings = new CloudRecordings(_fluentClient); Contacts = new Contacts(_fluentClient); DataCompliance = new DataCompliance(_fluentClient); Meetings = new Meetings(_fluentClient); PastMeetings = new PastMeetings(_fluentClient); PastWebinars = new PastWebinars(_fluentClient); Users = new Users(_fluentClient); Webinars = new Webinars(_fluentClient); Dashboards = new Dashboards(_fluentClient); }
// Token: 0x060002CE RID: 718 RVA: 0x0000A554 File Offset: 0x00008754 private static void ParseAccessToken(string rawToken, out string ewsAttachmentId) { ewsAttachmentId = null; try { ewsAttachmentId = OAuthTokenHandler.ValidateWacCallbackToken(rawToken); } catch (SecurityException innerException) { throw new OwaInvalidRequestException("Unable to parse WAC access token.", innerException); } catch (ArgumentException innerException2) { throw new OwaInvalidRequestException("Unable to parse WAC access token.", innerException2); } catch (InvalidOperationException innerException3) { throw new OwaInvalidRequestException("Unable to parse WAC access token.", innerException3); } }
public void ShouldSuccessfullyRetrieveBearerToken() { var config = new TestOAuthConfiguration { Url = _configuration["OdsApi:OAuthUrl"], Key = _configuration["OdsApi:Key"], Secret = _configuration["OdsApi:Secret"] }; Console.WriteLine(config.Url); Console.WriteLine($"key: {config.Key}"); Console.WriteLine($"secret: {config.Secret}"); var tokenRetriever = new TokenRetriever(config); var tokenHandler = new OAuthTokenHandler(tokenRetriever); var token = tokenHandler.GetBearerToken(); Console.WriteLine($"token: {token}"); Assert.IsTrue(!string.IsNullOrEmpty(token)); }
public void ShouldSuccessfullyRetrieveBearerToken() { var sandboxCredentials = SandboxCredentialsHelper.GetMinimalSandboxCredential(); var config = new TestOAuthConfiguration { Url = Settings.Default.OauthUrl, Key = sandboxCredentials.Key, Secret = sandboxCredentials.Secret }; Console.WriteLine(config.Url); Console.WriteLine($"key: {config.Key}"); Console.WriteLine($"secret: {config.Secret}"); var tokenRetriever = new TokenRetriever(config); var tokenHandler = new OAuthTokenHandler(tokenRetriever); var token = tokenHandler.GetBearerToken(); Console.WriteLine($"token: {token}"); Assert.IsTrue(!string.IsNullOrEmpty(token)); }