Logging In with the JS SDK

This guide explains how to log into the TigerConnect platform using the JS SDK.

Authentication

Authenticating with a Username and Password

This method allows you to sign in using a user ID and password.

Definition

client.signIn(
userId: string,
password: string,
options: ?Object
):Promise<Session,Error>

Parameters

ParameterTypeDescription
userIdstringAn email, username, or phone number
passwordstringThe user's password
options?ObjectOptions (described below)

Options

ParameterTypeDescription
refreshUser?booleanIndicates whether to fetch the user's latest information during sign in (default: true)
udidstringA unique identifier for the device

If you elect to call this method with refreshUser set to false, make sure to do a client.users.findMe({ bypassCache: true }) call later to fully load the current user.

Returns

An error will be thrown if any of the arguments are invalid.

Otherwise, once the returned Promise is resolved, we will have access to an object containing authentication and user information.

PropertyTypeDescription
authObjectAuthentication details
userObjectPartial User with some fields missing

Auth

PropertyTypeDescription
keystringAn authentication key
secretstringAn authentication secret
resourcestringThe generated resource token

Examples

const { user } = await client.signIn(
'someone@email.com',
's3cr3t',
{
udid: '3bc656cc-025b-49d1-aacf-ddf1b22a3a4b'
}
);
console.log(user.displayName);

Authenticating with an Existing API Key and Secret

This method allows you to sign in using a key and secret.

Definition

client.signInWithApiKeyAndSecret(
key: string,
secret: string
):Promise<Session,Error>

Parameters

ParameterTypeDescription
keystringAn authentication key
secretstringAn authentication secret

Returns

An error will be thrown if any of the arguments are invalid.

Otherwise, once the returned Promise is resolved, we will have access to an object containing authentication and user information.

PropertyTypeDescription
authObjectAuthentication details
userObjectPartial User with some fields missing

Auth

PropertyTypeDescription
keystringAn authentication key
secretstringAn authentication secret
resourcestringThe generated resource token

Examples

const { user } = await client.signInWithApiKeyAndSecret(
'myKey',
'mySecret',
{
udid: '3bc656cc-025b-49d1-aacf-ddf1b22a3a4b'
}
);
console.log(user.displayName);

Getting the Current User

This method retrieves an object representing the current user and their settings.

Definition

client.users.findMe(
options: ?Object
):Promise<Session,Error>

Parameters

ParameterTypeDescription
options?ObjectOptions (described below)

Options

ParameterTypeDescription
bypassCache?booleanIf true, always fetch from server, even if we already have a local copy

Returns

Once the returned Promise is resolved, we will have access to a User object of the current user.

Examples

const user = await client.users.findMe({ bypassCache: true });
console.log(user.displayName);

Getting the Current User Profiles

TigerConnect allows a user to be a part of multiple organizations and a user may have different profiles for each organization. As a result, we provide a method for obtaining all profiles that your user is associated with.

Definition

client.users.findMyProfilesForAllOrganizations():Promise<Object,Error>

Returns

When the call completes successfully, a promise will be returned with an object whose keys are organization IDs and the corresponding values being profile objects.

Each profile will contain the following properties.

PropertyTypeDescription
autoForwardReceiverIdsstring[]A list of user IDs chosen for auto forwarding
autoForwardReceiversUser[]A list of User models who will be forwarded incoming messages
departmentstringYour department within this organization
organizationIdstringThe organization ID this profile is associated with
titlestringYour title within this organization
userIdstringYour user ID

Example

const profiles = await client.users.findMyProfilesForAllOrganizations();
Object.entries(profiles).forEach(([organizationId, profile]) =>
console.table(profile)
);

Getting All Organizations

Retrieve all Organizations that the current user belongs to.

Definition

client.organizations.findAll():Promise<Organization[],Error>

Returns

An error will be thrown if any of the arguments are invalid.

Otherwise, once the returned Promise is resolved, you will have access to an array of Organizations.

Examples

const organizations = await client.organizations.findAll();
console.log(
'found',
organizations.length,
'organizations:',
organizations
.map(function(organization) {
return organization.name;
})
.join(', ')
);