# Accessing data exposed by the platform

You can access the data exposed by the platform through the IndustryApps **AAS Gateway**, which has REST endpoints provided by the IndustryApps Platform.  You will get an `AppID` and `AppSecretCode` when you register your application to IndustryApps in the Solution Provider portal. These credentials can be used to create an `AccessToken` . This AccessToken needs to be sent with every request of API. Along with this, you need to provide the`UserToken`which you will get from the below integration.

#### &#x20;Platform javascript API <a href="#id-2-1-platform-javascript-api" id="id-2-1-platform-javascript-api"></a>

import `platform-api.js` into main file (index.html) and invoke `getPlatformContext()` method. It will return an object with params:

* auth\_token
* euser
* plant\_selected
* language\_selected
* plant\_list
* company\_code
* roles

{% code title="index.html" %}

```html
<script src="https://cdn.uat.industryapps.net/cdn/js/v1/platform-api.js" type="text/javascript"></script>
```

{% endcode %}

```
// Example in Vue js
export default {
    head: {
        script: [
            { hid: 'getPlatformContext', 
            src: 'https://cdn.uat.industryapps.net/cdn/js/v1/platform-api.js', 
            defer: true }
        ]
    }
}

```

**API documentation**

**Methods**

`getPlatformContext() → {Object}` This function returns an object with params auth\_token, euser, plant\_selected, language\_selected, plant\_list, company\_code, roles.

Returns: `platformContext` Type:

```
-Object
```

```
// Call getPlatformContext() after adding the CDN script.
const userData = getPlatformContext();
// e.g. auth_token callable at: userData.auth_token
```

**Type Definitions**

<table><thead><tr><th width="203.9090909090909">Name</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>auth_token</td><td>string</td><td>Token to be used in the header of every service call (UserToken)</td></tr><tr><td>euser</td><td>string</td><td>User code of logged in user</td></tr><tr><td>language_selected</td><td>string</td><td>Language code of selected language, default is 'en'</td></tr><tr><td>plant_selected</td><td>string</td><td>Id of selected plant</td></tr><tr><td>plant_list</td><td>object array</td><td>plant list</td></tr><tr><td>company_code</td><td>string</td><td>Current company code</td></tr><tr><td>roles</td><td>string array</td><td>User roles</td></tr></tbody></table>

#### Sample Response

```json
{
    "auth_token": "eb837c91-bee4-4011-8af5-1f7af649be92",
    "euser": "heera@xeiex.com",
    "plant_selected": "1",
    "language_selected": "en",
    "plant_list": [
        {
            "plantId": 2,
            "plantName": "Kilsyth",
            "plantCode": "5698",
            "defaultPlant": false
        },
        {
            "plantId": 1,
            "plantName": "Brisbane 01",
            "plantCode": "0987",
            "defaultPlant": true
        }
    ],
    "company_code": "1234",
    "roles": [
        "GRP_M_ADD",
        "TOOL_CRD_VIEW",
        "SOP_A_VIEW",
        "TSOP_M_ADD",
        "QSOP_IU_DEL",
        "OPR_ACT_ADD",
        "VENDOR_M_EDIT",
        "PROC_TYP_M_DEL",
        "QSOP_V_VIEW",
        "COM_M_EDIT",
        "DTC_EDIT",
        "8e08d9_Add_VIEW",
        "MACH_M_EDIT",
        "SOP_M_ADD",
        "QC_VIEW"
    ]
}
```
