feat: fix refresh token

This commit is contained in:
Nevo David 2026-01-05 21:30:04 +07:00
parent c7b83ee361
commit fc349942b5
2 changed files with 16 additions and 2 deletions

View File

@ -135,8 +135,9 @@ export abstract class SocialAbstract {
}
if (
request.status === 401 &&
(handleError?.type === 'refresh-token' || !handleError)
(request.status === 401 &&
(handleError?.type === 'refresh-token' || !handleError)) ||
handleError?.type === 'refresh-token'
) {
throw new RefreshToken(
identifier,

View File

@ -32,6 +32,19 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider {
return 500;
}
override handleErrors(body: string):
| {
type: 'refresh-token' | 'bad-body';
value: string;
}
| undefined {
if (body.includes('Error validating access token')) {
return { type: 'refresh-token', value: 'Threads access token expired' };
}
return undefined;
}
async refreshToken(refresh_token: string): Promise<AuthTokenDetails> {
const { access_token } = await (
await this.fetch(