Hello,
We have a use case where we need to have two users log into the RC SDK and use the two instances for different purposes (SMS sending vs non-SMS API requests).
What we found is that when we create new SDK instances and then check the login status, the second instance will reflect the login status of the first. We are using "@ringcentral/sdk": "4.7.4"
Code below to demonstrate the issue:
const SDK = require('@ringcentral/sdk').SDK
async function getRingcentralClient({
server,
clientId,
clientSecret,
username,
extension,
password,
}) {
const sdk = new SDK({
server,
clientId,
clientSecret,
})
console.log(`checking login status for: `, username)
try {
await sdk.ensureLoggedIn()
} catch (e) {
console.log(`logging in ${username}`)
await sdk.login({
username,
password,
extension,
})
}
console.log(`returning sdk instance for ${username}`)
return sdk
}
module.exports = {
getRingcentralClient,
}
Code to test the above module/demonstrate the issue:
async function _testFn() {
const server = 'https://platform.devtest.ringcentral.com'
const clientId = 'myClientId'
const clientSecret = 'myClientSecret'
// root user
const rootUserCreds = {
username: '+1xxxyyyy4538',
password: 'myRootPassword',
extension: '101',
}
// sms service account user:
const smsServiceUserCreds = {
username: '+1aaabbbb1966',
password: 'myServiceUserPassword',
extension: '102',
}
await getRingcentralClient({
server,
clientId,
clientSecret,
...rootUserCreds,
})
console.log(`\n\n`)
await getRingcentralClient({
server,
clientId,
clientSecret,
...smsServiceUserCreds,
})
}
_testFn()
Output of running the code with valid credentials (notice that the logging in 1aaabbbb1966 output is missing!):
checking login status for: +1xxxyyy4538
logging in +1xxxyyy4538
returning sdk instance for +1xxxyyy4538
checking login status for: +1aaabbbb1966
returning sdk instance for +1aaabbbb1966
What we would expect (since we're creating a new sdk instance):
checking login status for: +1xxxyyy4538
logging in +1xxxyyy4538
returning sdk instance for +1xxxyyy4538
checking login status for: +1aaabbbb1966
logging in +1aaabbbb1966
returning sdk instance for +1aaabbbb1966
Hello,
We have a use case where we need to have two users log into the RC SDK and use the two instances for different purposes (SMS sending vs non-SMS API requests).
What we found is that when we create
newSDK instances and then check the login status, the second instance will reflect the login status of the first. We are using "@ringcentral/sdk": "4.7.4"Code below to demonstrate the issue:
Code to test the above module/demonstrate the issue:
Output of running the code with valid credentials (notice that the
logging in 1aaabbbb1966output is missing!):What we would expect (since we're creating a
newsdk instance):