Following the Authentication guide, the user must be authenticated to interact with the SDK.
Each login type is predefined for the website AppKey, for more details, see Authentication.
window.AE_SDK(async (thrownError, AE_SDK) => {
await AE_SDK.auth.login();
await AE_SDK.auth.login({ token });
await AE_SDK.auth.login({ name: 'user name' });
await AE_SDK.auth.logout();
});
export type AuthenticationApi = {
login: (loginData?: LoginData) => Promise<LoggedInPayload>;
logout: () => Promise<void>;
};
export type LoggedInPayload = { token: string; homeUserId: string };
Name | Type | Description |
auth.login | (loginData?: LoginData) => Promise<LoggedInPayload> | log the user in |
auth.logout | () => Promise | log the user out |
Calling the `login` API function more than once will override the previous login.
LoginData
Property | Type | Description | Default value |
token? | string (JWT) | when using token login | none |
name? | string | the name of the user, presented to the support expert | none |
mdn? | string | the MDN of the user | none |
imageUrl? | string | the image of the user, presented to the support expert | none |
correlationId? | string | a unique user id from the host website. used mostly for debugging | none |
If a token isn't given in the parameters, the SDK will assume the relevant login type is anonymous.
LoggedInPayload
Property | Type | Description |
token | string (JWT) | the SDK token that was used to login |
homeUserId | string | the unique identifier of the user given by the SDK |
Last updated on 3/29/2022 by gilm123