diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/ApplicationsApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/ApplicationsApiServiceImpl.java index 2a8fb667b78b..6771e0ecb807 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/ApplicationsApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/ApplicationsApiServiceImpl.java @@ -1026,11 +1026,12 @@ public Response applicationsApplicationIdKeysKeyTypePut(String applicationId, St String username = RestApiCommonUtil.getLoggedInUsername(); try { APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(username); - Application application = apiConsumer.getApplicationByUUID(applicationId); - if (!(apiConsumer.isKeyManagerAllowedForUser(body.getKeyManager(), username))) { + if (!(apiConsumer.isKeyManagerByNameAllowedForUser(body.getKeyManager(), + MultitenantUtils.getTenantDomain(username), username))) { throw new APIManagementException("Key Manager is permission restricted", ExceptionCodes.KEY_MANAGER_RESTRICTED_FOR_USER); } + Application application = apiConsumer.getApplicationByUUID(applicationId); if (application != null) { if (RestAPIStoreUtils.isUserOwnerOfApplication(application)) { String grantTypes = StringUtils.join(body.getSupportedGrantTypes(), ',');