EMSAdmin Authentication Token
An Authentication Token can be used to securely communicate with a service. It's a JWT token that contains the fields listed below.
An integration for the service must be defined in the Frontend Tokens section in EMS Admin. Calling the getter function with the name of the integration will return a promise that will be resolved with an Authentication Token.
This utility works in iframes as well, but the UI Kit must be present on top window otherwise the promise won't resolve. The promise will be rejected if top window's domain is not whitelisted in Suite configuration.
Usage
Name | Description |
---|---|
window.e.utils.v2.auth.getEMSAdminAuthenticationToken(integrationName) |
The authentication token utility is used to retrieve an Authentication Token. |
Parameters
Name | Type | Description |
---|---|---|
integrationName |
The name of the integration to get the Authentication Token for |
Return value
Type | Description |
---|---|
A promise that resolves to the Authentication token |
JWT Fields
The JWT decoded Authentication Token contains the following fields:
Name | Type | Description |
---|---|---|
customerId |
The customerId of the currently selected customer (if any) |
|
environment |
The name (domain) of the current environment | |
exp |
Expiration time (JWT token) | |
isAdmin |
Is the currently logged in staff member an admin | |
iss |
Token issuer (JWT token) | |
staffId |
The id of the current staff member logged in to EMSAdmin |
Example
window.e.utils.v2.auth.getEMSAdminAuthenticationToken('myIntegration').then(token => {
return getDataFromBackend(token);
});