diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index f57c2fadc6..5df0e841d8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -242,9 +242,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isAllowedAllDomains, String validityTime, TokenInfo tokenInfo) throws APIManagerException { + ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); try { List uniqueApiList = new ArrayList<>(); @@ -311,6 +313,16 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } } + + if (isNewApplication) { + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; + } else { + return null; + } } catch (APIServicesException e) { String msg = "Error occurred while processing the response of APIM REST endpoints."; log.error(msg, e);