diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java index 5fab1055a4..24d5b7cabd 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/consent/SelfSignUpConsentTest.java @@ -78,7 +78,7 @@ public class SelfSignUpConsentTest extends ISIntegrationTest { private static final String FINANCIAL = "Financial"; private static final String ERROR_MESSAGE_SELF_REGISTRATION_DISABLED = "Self registration is disabled for tenant" + " - %s"; - private static final String ERROR_MESSAGE_INVALID_TENANT = "Invalid tenant domain :%s"; + private static final String ERROR_MESSAGE_INVALID_TENANT = "%s is an invalid tenant domain"; private static final String ERROR_MESSAGE_USERNAME_TAKEN = "Username '%s' is already taken. Please pick a " + "different username"; @@ -141,6 +141,7 @@ public void testInitialSelfSignUpPage() throws IOException { HttpClient client = HttpClientBuilder.create().build(); String selfRegisterEndpoint = selfRegisterDoEndpoint + "?" + CALLBACK_QUERY_PARAM + "=" + CALLBACK_ENDPOINT; + selfRegisterEndpoint = getTenantQualifiedURL(selfRegisterEndpoint, secondaryTenantDomain); HttpResponse httpResponse = sendGetRequest(client, selfRegisterEndpoint); String content = DataExtractUtil.getContentData(httpResponse); Assert.assertNotNull(content); @@ -296,6 +297,7 @@ private String doCallSignUpDo(String username) throws IOException { } String selfRegisterEndpoint = signupDoEndpoint + "?" + USERNAME_QUERY_PARAM + "=" + username; + selfRegisterEndpoint = getTenantQualifiedURL(selfRegisterEndpoint, tenantDomain); HttpResponse httpResponse = sendGetRequest(client, selfRegisterEndpoint); return DataExtractUtil.getContentData(httpResponse); } @@ -434,12 +436,12 @@ private void selfRegister(String username, String password, String givenName, St private String getConsentReqBody(String purposeId, int piiCategoryId, String username) { - return "{\\\"jurisdiction\\\":\\\"someJurisdiction\\\",\\\"collectionMethod\\\":\\\"Web Form - Self " + + return "{\\\"jurisdiction\\\":\\\"someJurisdiction\\\",\\\"collectionMethod\\\":\\\"Web Form - Self " + "Registration\\\"," + "\\\"language\\\":\\\"en\\\",\\\"piiPrincipalId\\\":\\\""+username+"\\\",\\\"services\\\":" + "[{\\\"tenantDomain\\\":\\\"wso2.com\\\",\\\"serviceDisplayName\\\":\\\"Resident IDP\\\"," + "\\\"serviceDescription\\\":\\\"Resident IDP\\\",\\\"purposes\\\":[{\\\"purposeId\\\":"+purposeId+"," + - "\\\"purposeCategoryId\\\":[1]," + + "\\\"purposeCategoryId\\\":[1]," + "\\\"consentType\\\":\\\"EXPLICIT\\\",\\\"piiCategory\\\":[{\\\"piiCategoryId\\\":"+piiCategoryId+"," + "\\\"validity\\\":\\\"DATE_UNTIL:INDEFINITE\\\"}],\\\"primaryPurpose\\\":true," + "\\\"termination\\\":\\\"DATE_UNTIL:INDEFINITE\\\",\\\"thirdPartyDisclosure\\\":false}],\\\"tenantId\\\":1}]," + diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java index 33ed117f77..4841745672 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ResidentIDPConfigsTestCase.java @@ -140,7 +140,7 @@ public static Object[][] federatedAuthConfigURLProvider() { "Expected OAuth10a Authorize URL is not found in the tenant mode"}, {"wso2.com", "OAuth1RequestTokenUrl", "https://localhost:9853/oauth/request-token", "Expected OAuth10a Request Token URL is not found in the tenant mode"}, - {"wso2.com", "IdentityProviderUrl", "https://localhost:9853/passivests", + {"wso2.com", "IdentityProviderUrl", "https://localhost:9853/t/wso2.com/passivests", "Expected Passive STS URL is not found in the tenant mode"}, {"wso2.com", "OpenIdUrl", "https://localhost:9853/openidserver", "Expected OpenID Server URL is not found in the tenant mode"}, @@ -148,7 +148,7 @@ public static Object[][] federatedAuthConfigURLProvider() { "Expected ECP URL is not found in the tenant mode"}, {"wso2.com", "LogoutReqUrl", "https://localhost:9853/t/wso2.com/samlsso", "Expected Logout URL is not found in the tenant mode"}, - {"wso2.com", "ArtifactResolveUrl", "https://localhost:9853/samlartresolve", + {"wso2.com", "ArtifactResolveUrl", "https://localhost:9853/t/wso2.com/samlartresolve", "Expected Artifact Resolution URL is not found in the tenant mode"}, {"wso2.com", "SSOUrl", "https://localhost:9853/t/wso2.com/samlsso", "Expected SSO URL is not found in the tenant mode"}, @@ -156,15 +156,15 @@ public static Object[][] federatedAuthConfigURLProvider() { "Expected Security Token Service URL is not found in the tenant mode"}, {"wso2.com", "OIDCWebFingerEPUrl", "https://localhost:9853/.well-known/webfinger", "Expected Web finger Endpoint URL is not found in the tenant mode"}, - {"wso2.com", "OIDCCheckSessionEPUrl", "https://localhost:9853/oidc/checksession", + {"wso2.com", "OIDCCheckSessionEPUrl", "https://localhost:9853/t/wso2.com/oidc/checksession", "Expected Session IFrame Endpoint URL is not found in the tenant mode"}, {"wso2.com", "OAuth2IntrospectEPUrl", "https://localhost:9853/t/wso2.com/oauth2/introspect", "Expected Token Introspection Endpoint URL is not found in the tenant mode"}, - {"wso2.com", "OAuth2RevokeEPUrl", "https://localhost:9853/oauth2/revoke", + {"wso2.com", "OAuth2RevokeEPUrl", "https://localhost:9853/t/wso2.com/oauth2/revoke", "Expected Token Revocation Endpoint URL is not found in the tenant mode"}, - {"wso2.com", "OIDCLogoutEPUrl", "https://localhost:9853/oidc/logout", + {"wso2.com", "OIDCLogoutEPUrl", "https://localhost:9853/t/wso2.com/oidc/logout", "Expected Logout Endpoint URL not found in the tenant mode"}, - {"wso2.com", "OAuth2AuthzEPUrl", "https://localhost:9853/oauth2/authorize", + {"wso2.com", "OAuth2AuthzEPUrl", "https://localhost:9853/t/wso2.com/oauth2/authorize", "Expected Authorization Endpoint URL is not found in the tenant mode"}, {"wso2.com", "OAuth2DCREPUrl", "https://localhost:9853/t/wso2.com/api/identity/oauth2/dcr/v1.1/register", "Expected Dynamic Client Registration Endpoint URL is not found in the tenant mode"}, @@ -172,9 +172,9 @@ public static Object[][] federatedAuthConfigURLProvider() { "Expected Dynamic Client Registration Endpoint URL is not found in the tenant mode"}, {"wso2.com", "OAuth2JWKSPage", "https://localhost:9853/t/wso2.com/oauth2/jwks", "Expected OAuth2 JWKS Page is not found in the tenant mode"}, - {"wso2.com", "OAuth2TokenEPUrl", "https://localhost:9853/oauth2/token", + {"wso2.com", "OAuth2TokenEPUrl", "https://localhost:9853/t/wso2.com/oauth2/token", "Expected Token Endpoint URL is not found in the tenant mode"}, - {"wso2.com", "OAuth2UserInfoEPUrl", "https://localhost:9853/oauth2/userinfo", + {"wso2.com", "OAuth2UserInfoEPUrl", "https://localhost:9853/t/wso2.com/oauth2/userinfo", "Expected User Info Endpoint URL is not found in the tenant mode"} }; } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java index 535147d549..481e413a98 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java @@ -79,7 +79,7 @@ public void testInit() throws Exception { super.init(TestUserMode.TENANT_USER); - this.USERNAME = tenantInfo.getContextUser().getUserName(); + this.USERNAME = tenantInfo.getContextUser().getUserNameWithoutDomain(); this.PASSWORD = tenantInfo.getContextUser().getPassword(); setSystemproperties(); client = HttpClients.createDefault(); @@ -126,7 +126,8 @@ public void testRegisterApplication() throws Exception { "testRegisterApplication") public void testSendAuthorizedPost() throws Exception { - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost(getTenantQualifiedURL( + OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); @@ -159,7 +160,8 @@ public void testSendAuthorizedPostAfterRoleUpdate() throws Exception { scim2RestClient.updateUserRole(getAddUserPatchRole(userId), roleId); - HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost request = new HttpPost(getTenantQualifiedURL( + OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java index 659e2e5ff1..09f3c93b22 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java @@ -127,7 +127,7 @@ public void testGetTokenUsingClientCredentialsGrant() throws Exception { ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); Scope scope = new Scope(OAUTH2_SCOPE_OPENID, "xyz"); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, clientCredentialsGrant, scope); HTTPResponse tokenHTTPResp = request.toHTTPRequest().send(); Assert.assertNotNull(tokenHTTPResp, "Access token http response is null."); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java index 189074b81a..9034a86eca 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java @@ -142,7 +142,8 @@ public void testSendAuthorozedPost() throws Exception { urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); urlParameters.add(new BasicNameValuePair("scope", scopes)); urlParameters.add(new BasicNameValuePair("callbackurl", OAuth2Constant.CALLBACK_URL)); - urlParameters.add(new BasicNameValuePair("authorizeEndpoint", OAuth2Constant.APPROVAL_URL)); + urlParameters.add(new BasicNameValuePair("authorizeEndpoint", + getTenantQualifiedURL(OAuth2Constant.APPROVAL_URL, tenantInfo.getDomain()))); urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM)); urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java index f82a55ed2e..4f3db82aef 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java @@ -105,7 +105,7 @@ public void testGetAccessToken() throws Exception { urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret)); urlParameters.add(new BasicNameValuePair("accessEndpoint", - OAuth2Constant.ACCESS_TOKEN_ENDPOINT)); + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()))); urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM)); HttpResponse response = sendPostRequestWithParameters(client, urlParameters, diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java index 77471bc561..587cc8588e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java @@ -53,7 +53,7 @@ public class OAuth2ServiceRefreshTokenGrantTestCase extends OAuth2ServiceAbstrac @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(TestUserMode.SUPER_TENANT_USER); - adminUsername = userInfo.getUserName(); + adminUsername = userInfo.getUserNameWithoutDomain(); adminPassword = userInfo.getPassword(); setSystemproperties(); @@ -111,7 +111,8 @@ public void testRefreshTokenGrant() throws Exception { } private JSONObject responseObject(List postParameters) throws Exception { - HttpPost httpPost = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + HttpPost httpPost = new HttpPost(getTenantQualifiedURL( + OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); //generate post request httpPost.setHeader("Authorization", "Basic " + getBase64EncodedString(consumerKey, consumerSecret)); httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded"); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2XACMLScopeValidatorTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2XACMLScopeValidatorTestCase.java index 6df5532c6e..880c1172e2 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2XACMLScopeValidatorTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2XACMLScopeValidatorTestCase.java @@ -189,12 +189,12 @@ private boolean getTokenAndValidate(Scope scope) throws Exception { try { Secret password = new Secret(userInfo.getPassword()); - AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(userInfo.getUserName(), - password); + AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant( + userInfo.getUserNameWithoutDomain(), password); ClientID clientID = new ClientID(consumerKey); Secret clientSecret = new Secret(consumerSecret); ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, scope); HTTPResponse tokenHTTPResp = request.toHTTPRequest().send(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCDiscoveryTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCDiscoveryTestCase.java index a6cc5ceaa8..b41f4e769d 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCDiscoveryTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OIDCDiscoveryTestCase.java @@ -86,7 +86,7 @@ public void testWebFinger() throws IOException { Object links = ((JSONObject)obj).get("links"); Assert.assertNotNull(links); String openIdProviderIssuerLocation = ((JSONObject)((JSONArray)links).get(0)).get("href").toString(); - String urlExpected = isServerBackendUrl + "/oauth2/token"; + String urlExpected = getTenantQualifiedURL(isServerBackendUrl + "/oauth2/token", config.getTenant()); Assert.assertEquals(openIdProviderIssuerLocation, urlExpected); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java index 380880d0e1..0d364c51b1 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java @@ -118,12 +118,12 @@ private boolean getTokenAndValidate(Scope scope) throws Exception { try { Secret password = new Secret(userInfo.getPassword()); - AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(userInfo.getUserName(), - password); + AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant( + userInfo.getUserNameWithoutDomain(), password); ClientID clientID = new ClientID(consumerKey); Secret clientSecret = new Secret(consumerSecret); ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, scope); HTTPResponse tokenHTTPResp = request.toHTTPRequest().send(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/SystemScopePermissionValidationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/SystemScopePermissionValidationTestCase.java index dc140d410f..3b155d7da8 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/SystemScopePermissionValidationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/SystemScopePermissionValidationTestCase.java @@ -62,6 +62,7 @@ public class SystemScopePermissionValidationTestCase extends OAuth2ServiceAbstra private String consumerSecret; private CloseableHttpClient client; private final String username; + private final String usernameWithoutTenantDomain; private final String userPassword; private final String activeTenant; private final TestUserMode testUserMode; @@ -82,6 +83,7 @@ public SystemScopePermissionValidationTestCase(TestUserMode userMode) throws Exc super.init(userMode); AutomationContext context = new AutomationContext("IDENTITY", userMode); this.username = context.getContextTenant().getTenantAdmin().getUserName(); + this.usernameWithoutTenantDomain = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain(); this.userPassword = context.getContextTenant().getTenantAdmin().getPassword(); this.activeTenant = context.getContextTenant().getDomain(); this.testUserMode = userMode; @@ -127,7 +129,7 @@ public void testGetAccessToken() throws Exception { urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret)); urlParameters.add(new BasicNameValuePair("accessEndpoint", - OAuth2Constant.ACCESS_TOKEN_ENDPOINT)); + getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()))); urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM)); urlParameters.add(new BasicNameValuePair("scope", SYSTEM_SCOPE)); HttpResponse response = @@ -164,11 +166,12 @@ public void getTokenAndValidate() throws Exception { try { client = HttpClientBuilder.create().disableRedirectHandling().build(); Secret password = new Secret(userPassword); - AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(username, password); + AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant( + usernameWithoutTenantDomain, password); ClientID clientID = new ClientID(consumerKey); Secret clientSecret = new Secret(consumerSecret); ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); - URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())); Scope systemScope = new Scope(SYSTEM_SCOPE); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, systemScope);