User

The User Aptitude provides the ability to retrieve a JWT for the current user, which can be used to identify an Olive Helps user to a 3rd party service.

jwt

Provides the ability to generate a JWT for the current user and only valid for the requesting Loop.

import { user } from '@oliveai/ldk';

user.jwt().then((token) => {
    console.log(`User's JWT token: ${token}`);
});

An optional config object can be passed in. It is used to determine what optional claims to include in the JWT result.

import { user } from '@oliveai/ldk';

const config = { includeEmail: true };

user.jwt(config).then((token) => {
    console.log(`User's JWT token: ${token}`);
});

jwtWithUserDetails

Provides the ability to generate a JWT for the current user as well as get additional information about the user, such as full name and organization details.

import { user } from '@oliveai/ldk';

// Config object can include any of these parameters.
// NOTE: email is included in the encoded JWT, all others are attached
// on the returned object.
const jwtWithUserDetailsConfig = {
    includeEmail: true,
    includeFullName: true,
    includeOrganizationId: true,
    includeOrganizationName: true,
};

user.jwtWithUserDetails(jwtWithUserDetailsConfig).then((returnObj) => {
    console.log(`User's JWT token: ${returnObj.jwt}`);
    console.log(`User's Full Name: ${returnObj.fullName}`);
    console.log(`User's Organization ID: ${returnObj.organizationId}`);
    console.log(`User's Organization Name: ${returnObj.organizationName}`);
    console.log(`User's Email: ${returnObj.email}`);
});

Last updated