Skip to content

Commit b6b1e5a

Browse files
authored
handle invalid token error (#285)
1 parent 89c92ea commit b6b1e5a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/auth/authError.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import BaseError from '../utils/baseError';
22

33
export default class AuthError extends BaseError {
44
constructor(response) {
5-
const { status, json = {}, text } = response;
6-
const { error, error_description: description } = json;
5+
const {status, json = {}, text} = response;
6+
const {error, error_description: description} = json;
77
super(
88
error || 'a0.response.invalid',
9-
description || text || 'unknown error'
9+
description || text || handleInvalidToken(response) || 'unknown error',
1010
);
1111
this.json = json;
1212
this.status = status;
1313
}
1414
}
15+
16+
const handleInvalidToken = response =>
17+
response?.headers?.map['www-authenticate'].match(/error="invalid_token"/g)
18+
? 'invalid_token'
19+
: null;

0 commit comments

Comments
 (0)