Exemple #1
0
        /// <summary>
        /// Client Id and Secret for the OAuth
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="config"></param>
        public OAuthTokenCredential(string clientId = "", string clientSecret = "", Dictionary <string, string> config = null)
        {
            this.config = config != null?ConfigManager.GetConfigWithDefaults(config) : ConfigManager.GetConfigWithDefaults(ConfigManager.Instance.GetProperties());

            // Set the client ID.
            if (string.IsNullOrEmpty(clientId))
            {
                this.ClientId = this.config.ContainsKey(BaseConstants.ClientId) ? this.config[BaseConstants.ClientId] : string.Empty;
            }
            else
            {
                this.ClientId = clientId;
                this.config[BaseConstants.ClientId] = clientId;
            }

            // Set the client secret.
            if (string.IsNullOrEmpty(clientSecret))
            {
                this.ClientSecret = this.config.ContainsKey(BaseConstants.ClientSecret) ? this.config[BaseConstants.ClientSecret] : string.Empty;
            }
            else
            {
                this.ClientSecret = clientSecret;
                this.config[BaseConstants.ClientSecret] = clientSecret;
            }

            this.SdkVersion = new SDKVersion();
            this.AccessTokenExpirationSafetyGapInSeconds = 120; // Default is 2 minute safety gap for token expiration.
        }
        /// <summary>
        /// Client Id and Secret for the OAuth
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="config"></param>
        public OAuthTokenCredential(string clientId = "", string clientSecret = "", Dictionary<string, string> config = null)
        {
            this.config = config != null ? ConfigManager.GetConfigWithDefaults(config) : ConfigManager.GetConfigWithDefaults(ConfigManager.Instance.GetProperties());

            // Set the client ID.
            if(string.IsNullOrEmpty(clientId))
            {
                this.ClientId = this.config.ContainsKey(BaseConstants.ClientId) ? this.config[BaseConstants.ClientId] : string.Empty;
            }
            else
            {
                this.ClientId = clientId;
                this.config[BaseConstants.ClientId] = clientId;
            }

            // Set the client secret.
            if(string.IsNullOrEmpty(clientSecret))
            {
                this.ClientSecret = this.config.ContainsKey(BaseConstants.ClientSecret) ? this.config[BaseConstants.ClientSecret] : string.Empty;
            }
            else
            {
                this.ClientSecret = clientSecret;
                this.config[BaseConstants.ClientSecret] = clientSecret;
            }

            this.SdkVersion = new SDKVersion();
            this.AccessTokenExpirationSafetyGapInSeconds = 120; // Default is 2 minute safety gap for token expiration.
        }