diff --git a/components/org.wso2.carbon.identity.organization.management.application/src/main/java/org/wso2/carbon/identity/organization/management/application/OrgApplicationManagerImpl.java b/components/org.wso2.carbon.identity.organization.management.application/src/main/java/org/wso2/carbon/identity/organization/management/application/OrgApplicationManagerImpl.java index 4d6a92be3..75b816e51 100644 --- a/components/org.wso2.carbon.identity.organization.management.application/src/main/java/org/wso2/carbon/identity/organization/management/application/OrgApplicationManagerImpl.java +++ b/components/org.wso2.carbon.identity.organization.management.application/src/main/java/org/wso2/carbon/identity/organization/management/application/OrgApplicationManagerImpl.java @@ -318,19 +318,23 @@ private void revokeAccessTokensOfSharedApp(String rootOrganizationId, String roo throw handleServerException(ERROR_CODE_ERROR_RESOLVING_TENANT_DOMAIN_FROM_ORGANIZATION_DOMAIN, null, rootOrganizationId); } - ServiceProvider rootApplication = getOrgApplication(rootApplicationId, rootTenantDomain); - ServiceProvider sharedApplication = resolveSharedApplicationByMainAppUUID( - rootApplication.getApplicationResourceId(), rootOrganizationId, sharedOrganizationId); - if (sharedApplication.getInboundAuthenticationConfig() + String sharedAppTenantDomain = getOrganizationManager().resolveTenantDomain(sharedOrganizationId); + if (StringUtils.isBlank(sharedAppTenantDomain)) { + throw handleServerException(ERROR_CODE_ERROR_RESOLVING_TENANT_DOMAIN_FROM_ORGANIZATION_DOMAIN, null, + sharedOrganizationId); + } + + ServiceProvider rootApplication = getOrgApplication(rootApplicationId, rootTenantDomain); + if (rootApplication.getInboundAuthenticationConfig() .getInboundAuthenticationRequestConfigs().length != 0) { - String consumerKey = sharedApplication.getInboundAuthenticationConfig() + String consumerKey = rootApplication.getInboundAuthenticationConfig() .getInboundAuthenticationRequestConfigs()[0].getInboundAuthKey(); OAuthAppRevocationRequestDTO application = new OAuthAppRevocationRequestDTO(); application.setConsumerKey(consumerKey); try { OrgApplicationMgtDataHolder.getInstance().getOAuthAdminService() - .revokeIssuedTokensByApplication(application); + .revokeIssuedTokensByApplication(application, sharedAppTenantDomain); } catch (IdentityOAuthAdminException e) { throw new OrganizationManagementException("Error while revoking issued tokens for application: " + application.getConsumerKey(), e.getErrorCode());