Get Token Information

Get information about the user who is currently logged-in through the access token.

Request Format

GET https://{apigw-address}/app-portal-service/v2.1/session/info

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.

Response Parameters

Name Data Type Description
data Data Struct The details of the user who is currently logged-in. For more information, see Data Struct

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.

Samples

Request Sample

url: https://{apigw-address}/app-portal-service/v2.1/session/info
headers: {"Authorization":"yourBearerToken"}
method: GET

Return Sample

{
  "code": 200,
  "message": "",
  "data": {
    "userId": "yourUserId",
    "userName": "portal_demo",
    "currentOrgId": "yourOrgId",
    "currentOrgName": "Portal Demo"
  }
}

Java SDK Sample

public class AppPortalSdkTest{
    @Test
    public void getTokenInformationTest() {
        TokenInfoRequest tokenInfoRequest = new TokenInfoRequest("your_access_token");
        TokenInfoResponse tokenInfoResponse = Poseidon.config(PConfig.init().appKey("your_access_key").appSecret("your_secret_key").debug())
                .url("https://{apigw-address}").getResponse(tokenInfoRequest, TokenInfoResponse.class);

        System.out.println("Get token info res: " + JSON.toJSONString(tokenInfoResponse));

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