Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: fix refresh token

Nevo Davidfc349942b50d
diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.ts
index a3dd40e78..150d642a9 100644
--- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts
+++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts
@@ -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,
diff --git a/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts b/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts
index 5c852c4b0..fa8e0dc28 100644
--- a/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts
@@ -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(