Log In

Log in to the account.

Request Format

POST https://{apigw-address}/app-portal-service/v2.0/login

Request Parameters (Body)

Name

Mandatory/Optional

Data Type

Description

account

Mandatory

String

The user name.

password

Mandatory

String

The password of the user name.

Response Parameters

Name

Data Type

Description

data

Data Struct

The details of the user.

Data Struct

Name

Data Type

Description

organizations

Array of IdNamePair Structs

The list of organizations that the user belongs to.

user

IdNamePair Struct

The ID and name of the user.

accessToken

String

The access token, represented as bearer token.

IdNamePair Struct

Name

Data Type

Description

id

String

The organization/user ID.

name

String

The organization/user name.

Error Code

Code

Description

31400

User password is missing or not valid

31429

Attemp of accessing with incorrent password or IP reaches the limit. Please try again later.

Samples

Request Sample

url: https://{apigw-address}/app-portal-service/v2.0/login
{"account":"portal_demo","password":"yourPassword"}
method: POST

Return Sample

{
  "code": 200,
  "data": {
    "accessToken": "APP_PORTAL_S_WX89rC4pqsMc478tyP6gb9zFmT9qYaW7",
    "organizations": [
      {
        "id": "yourOrgId_1",
        "name": "Portal Demo"
      },
      {
        "id": "yourOrgId_2",
        "name": "rm_0726_001"
      }
    ],
    "user": {
      "id": "yourUserId",
      "name": "portal_demo"
    }
  },
  "message": ""
}

Java SDK Sample

public class AppPortalSdkTest{
    @Test
    public void loginTest() {
        LoginRequest loginRequest = new LoginRequest("your_user_name", "your_password");
        loginResponse = Poseidon.config(PConfig.init().appKey("your_access_key").appSecret("your_secret_key").debug())
                .url("https://{apigw-address}").getResponse(loginRequest, LoginResponse.class);
        System.out.println("Login res: " + JSON.toJSONString(loginResponse));

        assertNotNull("Response should not be null", loginResponse);
        assertNotNull("Response data should not be null", loginResponse.data);

        assertNotNull("Access token should not be null", loginResponse.data.accessToken);
        assertNotNull("User object should not be null", loginResponse.data.user);
        assertNotNull("Organizations should not be null", loginResponse.data.organizations);
        assertThat("Organizations should not be empty", loginResponse.data.organizations, not(IsEmptyCollection.empty()));
        assertThat("First organization should not be null", loginResponse.data.organizations.get(0), notNullValue());
    }
}