/// <summary> /// Initializes a new instance of the <see cref="OAuthConnectionInfo"/> class. /// </summary> /// <remarks> /// The authorization code is generated by Zoom when the user authorizes the app. /// This code can be used only one time to get the initial access token and refresh token. /// Once the authorization code has been used, is is no longer valid and should be discarded. /// </remarks> /// <param name="clientId">Your Client Id.</param> /// <param name="clientSecret">Your Client Secret.</param> /// <param name="authorizationCode">The authorization code.</param> /// <param name="onTokenRefreshed">The delegate invoked when the token is refreshed.</param> public OAuthConnectionInfo(string clientId, string clientSecret, string authorizationCode, OnTokenRefreshedDelegate onTokenRefreshed) { ClientId = clientId ?? throw new ArgumentNullException(nameof(clientId)); ClientSecret = clientSecret ?? throw new ArgumentNullException(nameof(clientSecret)); AuthorizationCode = authorizationCode ?? throw new ArgumentNullException(nameof(authorizationCode)); TokenExpiration = DateTime.MinValue; GrantType = OAuthGrantType.AuthorizationCode; OnTokenRefreshed = onTokenRefreshed; }
/// <summary> /// Initializes a new instance of the <see cref="OAuthConnectionInfo"/> class. /// </summary> /// <remarks> /// This is the most commonly used grant type for Zoom APIs. /// </remarks> /// <param name="clientId">Your Client Id.</param> /// <param name="clientSecret">Your Client Secret.</param> /// <param name="refreshToken">The refresh token.</param> /// <param name="accessToken">The access token. Access tokens expire after 1 hour. ZoomNet will automatically refresh this token when it expires.</param> /// <param name="onTokenRefreshed">The delegate invoked when the token is refreshed.</param> public OAuthConnectionInfo(string clientId, string clientSecret, string refreshToken, string accessToken, OnTokenRefreshedDelegate onTokenRefreshed) { ClientId = clientId ?? throw new ArgumentNullException(nameof(clientId)); ClientSecret = clientSecret ?? throw new ArgumentNullException(nameof(clientSecret)); RefreshToken = refreshToken ?? throw new ArgumentNullException(nameof(refreshToken)); AccessToken = accessToken ?? throw new ArgumentNullException(nameof(accessToken)); TokenExpiration = string.IsNullOrEmpty(accessToken) ? DateTime.MinValue : DateTime.MaxValue; // Set expiration to DateTime.MaxValue when an access token is provided because we don't know when it will expire GrantType = OAuthGrantType.RefreshToken; OnTokenRefreshed = onTokenRefreshed; }