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
Parameter | Type | Description |
---|---|---|
userId | string | An email, username, or phone number |
password | string | The user's password |
options | ?Object | Options (described below) |
Options
Parameter | Type | Description |
---|---|---|
refreshUser | ?boolean | Indicates whether to fetch the user's latest information during sign in (default: true ) |
udid | string | A 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.
Property | Type | Description |
---|---|---|
auth | Object | Authentication details |
user | Object | Partial User with some fields missing |
Auth
Property | Type | Description |
---|---|---|
key | string | An authentication key |
secret | string | An authentication secret |
resource | string | The 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
Parameter | Type | Description |
---|---|---|
key | string | An authentication key |
secret | string | An 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.
Property | Type | Description |
---|---|---|
auth | Object | Authentication details |
user | Object | Partial User with some fields missing |
Auth
Property | Type | Description |
---|---|---|
key | string | An authentication key |
secret | string | An authentication secret |
resource | string | The 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
Parameter | Type | Description |
---|---|---|
options | ?Object | Options (described below) |
Options
Parameter | Type | Description |
---|---|---|
bypassCache | ?boolean | If 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.
Property | Type | Description |
---|---|---|
autoForwardReceiverIds | string[] | A list of user IDs chosen for auto forwarding |
autoForwardReceivers | User[] | A list of User models who will be forwarded incoming messages |
department | string | Your department within this organization |
organizationId | string | The organization ID this profile is associated with |
title | string | Your title within this organization |
userId | string | Your 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(', '));