--- a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts
@@ -16,6 +16,20 @@
 import { Integration } from '@prisma/client';
 import { Rules } from '@gitroom/nestjs-libraries/chat/rules.description.decorator';
 
+// Test hooks, remove for upstream
+const TIKTOK_API_BASE =
+  process.env.TIKTOK_API_BASE || 'https://open.tiktokapis.com';
+const getExpiresIn = (expiresInResponse?: any): number => {
+  if (process.env.TIKTOK_FORCE_EXPIRES_IN) {
+    const forced = parseInt(process.env.TIKTOK_FORCE_EXPIRES_IN, 10);
+    if (!isNaN(forced)) {
+      return forced;
+    }
+  }
+  const parsed = Number(expiresInResponse);
+  return !isNaN(parsed) && parsed > 0 ? parsed : 7200;
+};
+
 @Rules(
   'TikTok can have one video or one picture or multiple pictures, it cannot be without an attachment'
 )
@@ -24,6 +38,7 @@
   name = 'Tiktok';
   isBetweenSteps = false;
   convertToJPEG = true;
+  refreshCron = true;
   scopes = [
     'video.list',
     'user.info.basic',
@@ -246,8 +261,8 @@
       refresh_token: refreshToken,
     };
 
-    const { access_token, refresh_token, ...all } = await (
-      await fetch('https://open.tiktokapis.com/v2/oauth/token/', {
+    const tokenResponse = await (
+      await fetch(`${TIKTOK_API_BASE}/v2/oauth/token/`, {
         headers: {
           'Content-Type': 'application/x-www-form-urlencoded',
         },
@@ -256,27 +271,66 @@
       })
     ).json();
 
-    const {
-      data: {
-        user: { avatar_url, display_name, open_id, username },
-      },
-    } = await (
-      await fetch(
-        'https://open.tiktokapis.com/v2/user/info/?fields=open_id,avatar_url,display_name,union_id,username',
-        {
-          method: 'GET',
-          headers: {
-            Authorization: `Bearer ${access_token}`,
-          },
-        }
-      )
-    ).json();
+    if (!tokenResponse?.access_token) {
+      const {
+        access_token: _at,
+        refresh_token: _rt,
+        ...safeErrorFields
+      } = tokenResponse || {};
+      const errCode =
+        tokenResponse?.error ||
+        tokenResponse?.code ||
+        tokenResponse?.data?.error_code ||
+        'unknown_error';
+      const errDesc =
+        tokenResponse?.error_description ||
+        tokenResponse?.message ||
+        tokenResponse?.data?.description ||
+        JSON.stringify(safeErrorFields);
+      const logId = tokenResponse?.log_id
+        ? ` (log_id: ${tokenResponse.log_id})`
+        : '';
+      throw new Error(
+        `TikTok refresh token failed: [${errCode}] ${errDesc}${logId}`
+      );
+    }
+
+    const { access_token, refresh_token, expires_in } = tokenResponse;
+
+    let open_id = '';
+    let display_name = '';
+    let avatar_url = '';
+    let username = '';
+
+    try {
+      const userInfoResponse = await (
+        await fetch(
+          `${TIKTOK_API_BASE}/v2/user/info/?fields=open_id,avatar_url,display_name,union_id,username`,
+          {
+            method: 'GET',
+            headers: {
+              Authorization: `Bearer ${access_token}`,
+            },
+          }
+        )
+      ).json();
+
+      const user = userInfoResponse?.data?.user;
+      if (user) {
+        avatar_url = user.avatar_url || '';
+        display_name = user.display_name || '';
+        open_id = user.open_id || '';
+        username = user.username || '';
+      }
+    } catch (err) {
+      // Best-effort profile fetch; ignore failure so rotated tokens are not lost
+    }
 
     return {
       refreshToken: refresh_token,
-      expiresIn: dayjs().add(23, 'hours').unix() - dayjs().unix(),
+      expiresIn: getExpiresIn(expires_in),
       accessToken: access_token,
-      id: open_id.replace(/-/g, ''),
+      id: open_id ? open_id.replace(/-/g, '') : '',
       name: display_name,
       picture: avatar_url || '',
       username: username,
@@ -323,8 +377,8 @@
       }${process?.env?.FRONTEND_URL}/integrations/social/tiktok`,
     };
 
-    const { access_token, refresh_token, scope } = await (
-      await fetch('https://open.tiktokapis.com/v2/oauth/token/', {
+    const tokenResponse = await (
+      await fetch(`${TIKTOK_API_BASE}/v2/oauth/token/`, {
         headers: {
           'Content-Type': 'application/x-www-form-urlencoded',
         },
@@ -333,6 +387,8 @@
       })
     ).json();
 
+    const { access_token, refresh_token, scope, expires_in } = tokenResponse;
+
     this.checkScopes(this.scopes, scope);
 
     const {
@@ -341,7 +397,7 @@
       },
     } = await (
       await fetch(
-        'https://open.tiktokapis.com/v2/user/info/?fields=open_id,avatar_url,display_name,union_id,username',
+        `${TIKTOK_API_BASE}/v2/user/info/?fields=open_id,avatar_url,display_name,union_id,username`,
         {
           method: 'GET',
           headers: {
@@ -356,7 +412,7 @@
       name: display_name,
       accessToken: access_token,
       refreshToken: refresh_token,
-      expiresIn: dayjs().add(23, 'hours').unix() - dayjs().unix(),
+      expiresIn: getExpiresIn(expires_in),
       picture: avatar_url,
       username: username,
     };
@@ -600,7 +656,7 @@
     try {
       // Get user stats (follower_count, following_count, likes_count, video_count)
       const userStatsResponse = await this.fetch(
-        'https://open.tiktokapis.com/v2/user/info/?fields=follower_count,following_count,likes_count,video_count',
+        `${TIKTOK_API_BASE}/v2/user/info/?fields=follower_count,following_count,likes_count,video_count`,
         {
           method: 'GET',
           headers: {
--- a/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts
+++ b/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts
@@ -16,32 +16,108 @@
     private _integrationService: IntegrationService,
     private _temporalService: TemporalService
   ) {}
-  async refresh(integration: Integration, cause = ''): Promise<false | AuthTokenDetails> {
-    const socialProvider = this._integrationManager.getSocialIntegration(
-      integration.providerIdentifier
-    );
-
-    const refresh = await this.refreshProcess(integration, socialProvider, cause);
 
-    if (!refresh) {
-      return false as const;
-    }
+  async refresh(
+    integration: Integration,
+    cause = ''
+  ): Promise<false | AuthTokenDetails> {
+    return this._integrationService.withIntegrationLock(
+      integration.id,
+      async (freshIntegration, tx) => {
+        if (!freshIntegration) {
+          return false as const;
+        }
+
+        const callerSnapshotRefreshToken = integration.refreshToken;
+        const storedRefreshToken = freshIntegration.refreshToken;
+        const now = Date.now();
+        const storedExpiration = freshIntegration.tokenExpiration
+          ? new Date(freshIntegration.tokenExpiration).getTime()
+          : 0;
+        const fiveMinutesMs = 5 * 60 * 1000;
+
+        // If another process already refreshed and the stored token is valid for > 5 minutes
+        if (
+          storedRefreshToken &&
+          storedRefreshToken !== callerSnapshotRefreshToken &&
+          storedExpiration > now + fiveMinutesMs
+        ) {
+          const secondsLeft = Math.max(
+            0,
+            Math.floor((storedExpiration - now) / 1000)
+          );
+          return {
+            accessToken: freshIntegration.token,
+            refreshToken: storedRefreshToken,
+            expiresIn: secondsLeft,
+            id: freshIntegration.internalId,
+            name: freshIntegration.name,
+            picture: freshIntegration.picture || '',
+            username: freshIntegration.profile || '',
+          };
+        }
+
+        const socialProvider = this._integrationManager.getSocialIntegration(
+          freshIntegration.providerIdentifier
+        );
+
+        // Call refreshProcess with the re-read row/token (never the snapshot token)
+        const refresh = await this.refreshProcess(
+          freshIntegration,
+          socialProvider,
+          cause,
+          callerSnapshotRefreshToken
+        );
+
+        if (!refresh) {
+          return false as const;
+        }
+
+        // Persist the new tokens before the lock is released. The full update (picture re-upload, profile, sibling
+        // channels) is best effort: TikTok has already invalidated the old refresh token, so a failure there must
+        // never lose the new one. The minimal update below runs last, on the lock transaction, and always commits.
+        try {
+          await this._integrationService.createOrUpdateIntegration(
+            undefined,
+            !!socialProvider.oneTimeToken,
+            freshIntegration.organizationId,
+            freshIntegration.name,
+            freshIntegration.picture!,
+            'social',
+            freshIntegration.internalId,
+            freshIntegration.providerIdentifier,
+            refresh.accessToken,
+            refresh.refreshToken,
+            refresh.expiresIn,
+            refresh.username || freshIntegration.profile
+          );
+        } catch (err) {
+          console.error(
+            `Refresh of ${freshIntegration.providerIdentifier} channel ${freshIntegration.id}: profile update failed, tokens still saved`,
+            err instanceof Error ? err.message : err
+          );
+        }
+
+        await tx.integration.update({
+          where: { id: freshIntegration.id },
+          data: {
+            token: refresh.accessToken,
+            refreshToken: refresh.refreshToken,
+            ...(refresh.expiresIn
+              ? {
+                  tokenExpiration: new Date(
+                    Date.now() + refresh.expiresIn * 1000
+                  ),
+                }
+              : {}),
+            refreshNeeded: false,
+            deletedAt: null,
+          },
+        });
 
-    await this._integrationService.createOrUpdateIntegration(
-      undefined,
-      !!socialProvider.oneTimeToken,
-      integration.organizationId,
-      integration.name,
-      integration.picture!,
-      'social',
-      integration.internalId,
-      integration.providerIdentifier,
-      refresh.accessToken,
-      refresh.refreshToken,
-      refresh.expiresIn
+        return refresh;
+      }
     );
-
-    return refresh;
   }
 
   public async setBetweenSteps(integration: Integration, cause = '') {
@@ -53,7 +129,11 @@
     );
   }
 
-  public async startRefreshWorkflow(orgId: string, id: string, integration: SocialProvider) {
+  public async startRefreshWorkflow(
+    orgId: string,
+    id: string,
+    integration: SocialProvider
+  ) {
     if (!integration.refreshCron) {
       return false;
     }
@@ -62,7 +142,7 @@
       .getRawClient()
       ?.workflow.start(`refreshTokenWorkflow`, {
         workflowId: `refresh_${id}`,
-        args: [{integrationId: id, organizationId: orgId}],
+        args: [{ integrationId: id, organizationId: orgId }],
         taskQueue: 'main',
         workflowIdConflictPolicy: 'TERMINATE_EXISTING',
       });
@@ -71,13 +151,31 @@
   private async refreshProcess(
     integration: Integration,
     socialProvider: SocialProvider,
-    cause = ''
+    cause = '',
+    snapshotRefreshToken = ''
   ): Promise<AuthTokenDetails | false> {
     const refresh: false | AuthTokenDetails = await socialProvider
       .refreshToken(integration.refreshToken)
       .catch((err) => false);
 
     if (!refresh || !refresh.accessToken) {
+      // Check if the stored row has meanwhile changed to a newer refresh token
+      const currentRow = await this._integrationService.getIntegrationById(
+        integration.organizationId,
+        integration.id
+      );
+
+      const hasNewerToken =
+        currentRow?.refreshToken &&
+        currentRow.refreshToken !== integration.refreshToken &&
+        (!snapshotRefreshToken ||
+          currentRow.refreshToken !== snapshotRefreshToken);
+
+      if (hasNewerToken) {
+        // Do not mark refreshNeeded or disconnect if another process has updated the token
+        return false;
+      }
+
       await this._integrationService.refreshNeeded(
         integration.organizationId,
         integration.id
--- a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts
@@ -1,5 +1,8 @@
-import { PrismaRepository } from '@gitroom/nestjs-libraries/database/prisma/prisma.service';
-import { Injectable } from '@nestjs/common';
+import {
+  PrismaRepository,
+  PrismaService,
+} from '@gitroom/nestjs-libraries/database/prisma/prisma.service';
+import { Injectable, Optional } from '@nestjs/common';
 import dayjs from 'dayjs';
 import { Integration } from '@prisma/client';
 import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
@@ -16,9 +19,35 @@
     private _plugs: PrismaRepository<'plugs'>,
     private _exisingPlugData: PrismaRepository<'exisingPlugData'>,
     private _customers: PrismaRepository<'customer'>,
-    private _mentions: PrismaRepository<'mentions'>
+    private _mentions: PrismaRepository<'mentions'>,
+    @Optional() private _prisma?: PrismaService
   ) {}
 
+  async withIntegrationLock<T>(
+    id: string,
+    callback: (integration: Integration | null, tx: any) => Promise<T>
+  ): Promise<T> {
+    const prisma: any =
+      this._prisma ||
+      (this._integration as any)?.prisma ||
+      (this._integration as any)?._prisma ||
+      (this._integration as any)?.model;
+
+    return prisma.$transaction(
+      async (tx: any) => {
+        await tx.$executeRaw`SELECT pg_advisory_xact_lock(hashtext('postiz_integration_' || ${id}))`;
+        const fresh = await tx.integration.findUnique({
+          where: { id },
+        });
+        return callback(fresh, tx);
+      },
+      {
+        maxWait: 90000,
+        timeout: 90000,
+      }
+    );
+  }
+
   getMentions(platform: string, q: string) {
     return this._mentions.model.mentions.findMany({
       where: {
@@ -281,7 +310,7 @@
             }
           : {}),
         ...(picture ? { picture } : {}),
-        profile: username,
+        ...(username ? { profile: username } : {}),
         providerIdentifier: provider,
         token,
         refreshToken,
@@ -368,7 +397,6 @@
         id,
       },
       data: {
-        ...(name ? { name } : {}),
         ...(url ? { picture: url } : {}),
       },
     });
--- a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts
@@ -41,6 +41,13 @@
     private _temporalService: TemporalService
   ) {}
 
+  async withIntegrationLock<T>(
+    id: string,
+    callback: (integration: Integration | null, tx: any) => Promise<T>
+  ): Promise<T> {
+    return this._integrationRepository.withIntegrationLock(id, callback);
+  }
+
   async changeActiveCron(orgId: string) {
     const data = await this._autopostsRepository.getAutoposts(orgId);
 
--- a/apps/orchestrator/src/workflows/refresh.token.workflow.ts
+++ b/apps/orchestrator/src/workflows/refresh.token.workflow.ts
@@ -31,25 +31,33 @@
 
     const today = new Date();
     const endDate = new Date(integration.tokenExpiration);
+    const remainingMs = Math.max(0, endDate.getTime() - today.getTime());
 
-    const minMax = Math.max(0, endDate.getTime() - today.getTime());
-    if (!minMax) {
-      return false;
-    }
+    // Refresh ahead of expiry: 15 minutes early, or half the remaining lifetime when that is shorter
+    // (a TikTok access token lives 2 hours; the half rule only matters for forced short test expiries).
+    const LEAD_TIME_MS = 15 * 60 * 1000;
+    const leadMs = Math.min(LEAD_TIME_MS, Math.floor(remainingMs / 2));
+    const waitTimeMs = Math.max(0, remainingMs - leadMs);
 
-    await sleep(minMax as number);
+    if (waitTimeMs > 0) {
+      await sleep(waitTimeMs);
 
-    // while we were sleeping, the integration might have been deleted
-    integration = await getIntegrationsById(integrationId, organizationId);
-    if (
-      !integration ||
-      integration.deletedAt ||
-      integration.inBetweenSteps ||
-      integration.refreshNeeded
-    ) {
-      return false;
+      // while we were sleeping, the integration might have been deleted
+      integration = await getIntegrationsById(integrationId, organizationId);
+      if (
+        !integration ||
+        integration.deletedAt ||
+        integration.inBetweenSteps ||
+        integration.refreshNeeded
+      ) {
+        return false;
+      }
     }
 
-    await refreshToken(integration);
+    // A failed refresh ends the loop (the refresh service has already flagged the channel); never retry in a tight loop.
+    const refreshed = await refreshToken(integration);
+    if (!refreshed) {
+      return false;
+    }
   }
 }
