From 69437a3b91aa3a81b26d4a15e1763257fe8c9275 Mon Sep 17 00:00:00 2001 From: Elridge D'Mello Date: Wed, 31 May 2023 19:08:26 -0500 Subject: [PATCH] Add docs on use of cachePrefix based on findings in this issue: https://github.com/ringcentral/ringcentral-js/issues/214 --- sdk/README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/sdk/README.md b/sdk/README.md index 9f90ead4..06a38f80 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -220,6 +220,41 @@ rcsdk }); ``` +### Multi User Login + +If you need to have multiple users login in to different instances of the sdk, you can use the `cachePrefix` SDK option. Specify different `cachePrefix` values for each instance. + +```js +const rcsdk1 = new RingCentral.SDK({ + server: RingCentral.SDK.server.sandbox, + clientId: 'yourClientId', + clientSecret: 'yourClientSecret', + cachePrefix: 'user1', +}); + +rcsdk1.login({ + username: '18001234567', + extension: '101', + password: 'password1' +}) + +const rcsdk2 = new RingCentral.SDK({ + server: RingCentral.SDK.server.sandbox, + clientId: 'yourClientId', + clientSecret: 'yourClientSecret', + cachePrefix: 'user2', +}); + +rcsdk1.login({ + username: '18005557777', + extension: '102', + password: 'password2' +}) + +``` +This prevents login state from being shared between the two instances `rcsdk1` and `rcsdk2` + + ## Handling login success Because the login process is asynchronous, you need to call the promise's `then` method and pass your success handler as