/** * Returns a string representing an authorization token for Endless Aisle * This value is required when creating any EA controllers * If there is a previously cached EA token, that will be returned instead * * @return _cachedEaAuthToken An Endless Aisle authorization token */ public static string GetEaAuthToken() { if (!string.IsNullOrEmpty(_cachedEaAuthToken)) { return(_cachedEaAuthToken); } var eaAuthController = new Controllers.EndlessAisle.AuthController(); //Read authentication information from config var eaClientSecret = ConfigReader.EaClientSecret; var eaClientId = ConfigReader.EaClientId; var eaUsername = ConfigReader.EaUsername; var eaPassword = ConfigReader.EaPassword; var eaGrantType = ConfigReader.EaGrantType; var eaCredentials = new AuthenticationCredentialsResource() { client_id = eaClientId, client_secret = eaClientSecret, grant_type = eaGrantType, username = eaUsername, password = eaPassword }; _cachedEaAuthToken = eaAuthController.Authenticate(eaCredentials); return(_cachedEaAuthToken); }
/** * Returns a string representing an authorization token for Magento * This value is required when creating any Magento controllers * If there is a previously cached Magento token, that will be returned instead * * @return _cachedMagentoAuthToken A magento authorization token */ public static string GetMagentoAuthToken() { if (!string.IsNullOrEmpty(_cachedMagentoAuthToken)) { return(_cachedMagentoAuthToken); } var magentoAuthController = new Controllers.Magento.AuthController(); //Read authentication information from config var magentoUsername = ConfigReader.MagentoUserName; var magentoPassword = ConfigReader.MagentoPassword; var magentoCredentials = new AuthenticationCredentialsResource { username = magentoUsername, password = magentoPassword }; _cachedMagentoAuthToken = magentoAuthController.Authenticate(magentoCredentials); return(_cachedMagentoAuthToken); }