/// <summary>
        /// Get the latest AD token given the reseller domain and client credentials
        /// </summary>
        /// <param name="domain">domain of the reseller</param>
        /// <param name="clientId">clientID of the application</param>
        /// <param name="clientSecret">client secret of the application, also refered to as key</param>
        /// <param name="adAuthorizationToken">ad authorization token, can be null</param>
        /// <returns>Latest AD Authorization token</returns>
        public static AuthorizationToken GetAD_Token(string domain, string clientId, string clientSecret, AuthorizationToken adAuthorizationToken = null)
        {
            if (adAuthorizationToken == null || (adAuthorizationToken != null && adAuthorizationToken.IsNearExpiry()))
            {
                //// Refresh the token on one of two conditions
                //// 1. If the token has never been retrieved
                //// 2. If the token is near expiry
                var adToken = GetADToken(domain, clientId, clientSecret);
                adAuthorizationToken = new AuthorizationToken(adToken.access_token.ToString(), Convert.ToInt64(adToken.expires_in.ToString()));
            }

            return adAuthorizationToken;
        }
        /// <summary>
        /// Get the latest sales agent token given the AD Authorization Token
        /// </summary>
        /// <param name="adAuthorizationToken">AD Authorization Token</param>
        /// <param name="saAuthorizationToken">Sales agent authorization token, can be null</param>
        /// <returns>Latest sales agent token</returns>
        public static AuthorizationToken GetSA_Token(AuthorizationToken adAuthorizationToken, AuthorizationToken saAuthorizationToken = null)
        {
            if (saAuthorizationToken == null || (saAuthorizationToken != null && saAuthorizationToken.IsNearExpiry()))
            {
                //// Refresh the token on one of two conditions
                //// 1. If the token has never been retrieved
                //// 2. If the token is near expiry
                
                var saToken = GetSA_Token(adAuthorizationToken.AccessToken);
                saAuthorizationToken = new AuthorizationToken(saToken.access_token.ToString(), Convert.ToInt64(saToken.expires_in.ToString()));
            }

            return saAuthorizationToken;
        }