Add: recognize token error as grant error
This commit is contained in:
parent
0d283a8396
commit
66220848f1
|
@ -220,6 +220,7 @@ const syncMan = (() => {
|
|||
function isGrantError(err) {
|
||||
if (err.code === 401) return true;
|
||||
if (err.code === 400 && /invalid_grant/.test(err.message)) return true;
|
||||
if (err.name === 'TokenError') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,17 @@ const tokenMan = (() => {
|
|||
|
||||
let alwaysUseTab = FIREFOX ? false : null;
|
||||
|
||||
class TokenError extends Error {
|
||||
constructor(provider, message) {
|
||||
super(`[${provider}] ${message}`);
|
||||
this.name = 'TokenError';
|
||||
this.provider = provider;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, TokenError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
buildKeys(name, hooks) {
|
||||
|
@ -112,17 +123,6 @@ const tokenMan = (() => {
|
|||
},
|
||||
};
|
||||
|
||||
class TokenError extends Error {
|
||||
constructor(provider, message) {
|
||||
super(`[${provider}] ${message}`);
|
||||
this.name = 'TokenError';
|
||||
this.provider = provider;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, TokenError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshToken(name, k, obj) {
|
||||
if (!obj[k.REFRESH]) {
|
||||
throw new TokenError(name, 'No refresh token');
|
||||
|
|
Loading…
Reference in New Issue
Block a user