Skip to content

Commit

Permalink
(GH-269) Add a parameter for token_index
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Feb 25, 2023
1 parent 77c314a commit dfab1ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Source/ZoomNet/OAuthConnectionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public class OAuthConnectionInfo : IConnectionInfo
/// </summary>
public string CodeVerifier { get; private set; }

/// <summary>
/// Gets the token index.
/// </summary>
public int TokenIndex { get; private set; }

/// <summary>
/// Initializes a new instance of the <see cref="OAuthConnectionInfo"/> class.
/// </summary>
Expand Down Expand Up @@ -325,8 +330,9 @@ public static OAuthConnectionInfo WithRefreshToken(string clientId, string clien
/// <param name="clientSecret">Your Client Secret.</param>
/// <param name="accountId">Your Account Id.</param>
/// <param name="onTokenRefreshed">The delegate invoked when the token is refreshed. In the Server-to-Server scenario, this delegate is optional.</param>
/// <param name="tokenIndex">The token index.</param>
/// <returns>The connection info.</returns>
public static OAuthConnectionInfo WithAccountId(string clientId, string clientSecret, string accountId, OnTokenRefreshedDelegate onTokenRefreshed = null)
public static OAuthConnectionInfo WithAccountId(string clientId, string clientSecret, string accountId, OnTokenRefreshedDelegate onTokenRefreshed = null, int tokenIndex = 0)
{
if (string.IsNullOrEmpty(clientId)) throw new ArgumentNullException(nameof(clientId));
if (string.IsNullOrEmpty(clientSecret)) throw new ArgumentNullException(nameof(clientSecret));
Expand All @@ -340,6 +346,7 @@ public static OAuthConnectionInfo WithAccountId(string clientId, string clientSe
TokenExpiration = DateTime.MinValue,
GrantType = OAuthGrantType.AccountCredentials,
OnTokenRefreshed = onTokenRefreshed,
TokenIndex = tokenIndex,
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions Source/ZoomNet/Utilities/OAuthTokenHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public string RefreshTokenIfNecessary(bool forceRefresh)
{ "grant_type", _connectionInfo.GrantType.ToEnumString() },
};

if (_connectionInfo.TokenIndex != 0) contentValues.Add("token_index", _connectionInfo.TokenIndex.ToString());

switch (_connectionInfo.GrantType)
{
case OAuthGrantType.AccountCredentials:
Expand Down

0 comments on commit dfab1ab

Please sign in to comment.