Choose Organization

Select the organization that the user needs to use after login.

Request Format

POST https://{apigw-address}/app-portal-service/v2.1/session/set

Request Parameters (Header)

Name Mandatory/Optional Data Type Description
Authorization Mandatory String The access token (or bearer token). Refer to Log In or Refresh Access Token to learn how to get the access token.

Request Parameters (Body)

Name Mandatory/Optional Data Type Description
orgId Mandatory String The organization ID.

Response Parameters

Name Data Type Description
data Data Struct The details of the organization.

data Struct

Name Data Type Description
userId String The user ID.
userName String The user name.
currentOrgId String The current organization ID.
currentOrgName String The current organization name.
accessToken String The access token in the request.
refreshToken String The new refresh token.
refreshTokenExpire String The refresh token expiration time in UTC format. For the time format, see ISO8601 Standard Time Formats Used by UTC

Samples

Request Sample

url: https://{apigw-address}/app-portal-service/v2.1/session/set
headers: {"Authorization":"yourBearerToken"}
method: POST
requestBody:
{
  "orgId":"yourOrgId"
}

Return Sample

{
  "code": 200,
  "message": "",
  "data": {
    "userId": "yourUserId",
    "userName": "portal_demo",
    "currentOrgId": "yourOrgId",
    "currentOrgName": "Portal Demo",
    "accessToken": "yourBearerToken",
    "refreshToken": "yourRefreshToken",
    "refreshTokenExpire": 1570018958000
  }
}

Java SDK Sample

public class AppPortalSdkTest{
    @Test
    public void chooseOrganizationTest() {
        String organizationId = "your_org_id";
        ChooseOrganizationRequest chooseOrganizationRequest = new ChooseOrganizationRequest(organizationId, "your_access_token");
        chooseOrganizationResponse = Poseidon.config(PConfig.init().appKey("your_access_key").appSecret("your_secret_key").debug())
                .url("https://{apigw-address}").getResponse(chooseOrganizationRequest, ChooseOrganizationResponse.class);

        System.out.println("List organization res: " + JSON.toJSONString(chooseOrganizationResponse));

        assertNotNull("Response should not be null", chooseOrganizationResponse);
        assertNotNull("Response data should not be null", chooseOrganizationResponse.data);
        assertNotNull("UserId should not be null", chooseOrganizationResponse.data.userId);

        refreshToken = chooseOrganizationResponse.data.refreshToken;
        assertNotNull("Refresh token should not be null", refreshToken);
    }
}