Attempt to re-authenticate on auth refresh error
This commit is contained in:
parent
2668f4d814
commit
bc7500ce3e
22
src/index.ts
22
src/index.ts
@ -68,16 +68,24 @@ async function initRingCentralSDK() {
|
|||||||
clientId: process.env.RC_APP_KEY,
|
clientId: process.env.RC_APP_KEY,
|
||||||
clientSecret: process.env.RC_APP_SECRET,
|
clientSecret: process.env.RC_APP_SECRET,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const login = () =>
|
||||||
|
sdk.login({
|
||||||
|
username: process.env.RC_LOGIN_USERNAME,
|
||||||
|
extension: process.env.RC_LOGIN_EXT,
|
||||||
|
password: process.env.RC_LOGIN_PASSWORD,
|
||||||
|
});
|
||||||
|
|
||||||
const platform = sdk.platform();
|
const platform = sdk.platform();
|
||||||
platform.on(platform.events.refreshError, (err) => {
|
platform.on(platform.events.refreshError, async (err) => {
|
||||||
console.error(err);
|
console.error("Refresh token error:", err);
|
||||||
});
|
await login();
|
||||||
await sdk.login({
|
console.log("RingCentral re-authentication successful.");
|
||||||
username: process.env.RC_LOGIN_USERNAME,
|
|
||||||
extension: process.env.RC_LOGIN_EXT,
|
|
||||||
password: process.env.RC_LOGIN_PASSWORD,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await login();
|
||||||
console.log("Authenticated to RingCentral.");
|
console.log("Authenticated to RingCentral.");
|
||||||
|
|
||||||
return sdk;
|
return sdk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user