-
Notifications
You must be signed in to change notification settings - Fork 456
Open
Description
After attempting to obtain an access token using service.getAccessToken(), I am accessing service.lastError_ in the catch block. However, this is undefined. Having looked at the source code, I see service.lastError_ is only assigned if canGetToken is true.
I believe in this case canGetToken is false because I haven't authenticated yet. Actually, I have, but my userProperties got cleared which has lost the stored token information; I need my catch block to re-run the authentication.
Is it possible for the source code to be amended, so that service.lastError_ gets assigned if canGetToken is false?
For context, this is my current code
function getAccessToken_() {
try {
return monzoService.getAccessToken();
} catch {
const msg = monzoService.lastError_.message;
if (msg.includes('Client not found')) {
...obtain correct Client ID from user...
monzoService = getMonzoService_();
return getAccessToken_()
} else if (msg.includes('Could not authenticate with provided credentials')) {
...obtain correct Client secret from user...
monzoService = getMonzoService_();
return getAccessToken_()
} else if (msg.includes('Bad refresh token')) {
reauthorise_();
} else {
throw new Error(msg);
}
}
}
Ideally msg will have some flag that will tell me I need to run reauthorise_, when canGetToken is false.
Metadata
Metadata
Assignees
Labels
No labels