public static void Initialize(string domainSuffix, Dictionary <string, string> configData) { try { if (configData == null) { AddConfigurationData("oauth_configuration"); } else { AddConfigurationData(configData); } List <string> MandatoryKeys = new List <string>() { ZohoOAuthConstants.CLIENT_ID, ZohoOAuthConstants.CLIENT_SECRET, ZohoOAuthConstants.PERSISTENCE_HANDLER_CLASS, ZohoOAuthConstants.REDIRECT_URL }; foreach (string key in MandatoryKeys) { if (ConfigProperties.ContainsKey(key)) { if (string.IsNullOrEmpty(ConfigProperties[key]) || string.IsNullOrWhiteSpace(ConfigProperties[key])) { throw new ZCRMException(key + " value is not set"); } } else { throw new ZCRMException(key + " is Mandatory"); } } //set iamURL from ConfigProperties if (ConfigProperties.ContainsKey(ZohoOAuthConstants.IAM_URL)) { if (string.IsNullOrEmpty(ConfigProperties[ZohoOAuthConstants.IAM_URL]) || string.IsNullOrWhiteSpace(ConfigProperties[ZohoOAuthConstants.IAM_URL])) { SetIAMUrl(domainSuffix); } } else { SetIAMUrl(domainSuffix); } ZohoOAuthParams oAuthParams = new ZohoOAuthParams() { ClientId = GetConfigValue(ZohoOAuthConstants.CLIENT_ID), ClientSecret = GetConfigValue(ZohoOAuthConstants.CLIENT_SECRET), AccessType = GetConfigValue(ZohoOAuthConstants.ACCESS_TYPE) ?? "offline", RedirectURL = GetConfigValue(ZohoOAuthConstants.REDIRECT_URL) }; ZohoOAuthClient.GetInstance(oAuthParams); ZCRMLogger.LogInfo("Zoho OAuth Client Library configuration properties: " + CommonUtil.DictToString(ConfigProperties)); } catch (KeyNotFoundException e) { ZCRMLogger.LogError("Exception while initializing Zoho OAuth Client .. Essential configuration data not found"); throw new ZohoOAuthException(e); } }
//TODO: Throw exceptions public static void Initialize(string domainSuffix, string configFileName) { SetIAMUrl(domainSuffix); AddConfigurationData("oauth_configuration"); if (configFileName != null) { AddConfigurationData(configFileName); } //TODO:Delete the following code after completion; Console.WriteLine("OAuth Inititalization Configurations:"); foreach (KeyValuePair <string, string> configuration in configProperties) { Console.WriteLine(configuration.Key + " : " + configuration.Value); } //End region; ZohoOAuthParams oAuthParams = new ZohoOAuthParams() { ClientId = GetConfigValue("client_id"), ClientSecret = GetConfigValue("client_secret"), AccessType = GetConfigValue("access_type"), RedirectURL = GetConfigValue("redirect_uri"), Scopes = GetConfigValue("scope") }; ZohoOAuthClient.GetInstance(oAuthParams); //TODO: Log the configuration properties; //TODO: Refer Java SDK for exceptions; }
public static ZohoOAuthClient GetInstance(ZohoOAuthParams oAuthParams) { client = client ?? new ZohoOAuthClient(oAuthParams); return(client); }
public ZohoOAuthClient(ZohoOAuthParams oAuthParams) { this.oAuthParams = oAuthParams; }