transloadit/uppy · error · Error

Could not load authentication data required for third-party

Error message

Could not load authentication data required for third-party login. Please try again later.

What it means

Thrown by Provider.ensurePreAuth when the plugin is configured with companionKeysParams (i.e. it must fetch a short-lived pre-auth token from Companion before OAuth) but fetchPreAuthToken() failed to obtain one. It aborts the third-party login flow early instead of proceeding with an invalid session. Typically the underlying cause is a network failure or a Companion server error, which surfaces in the console as a separate logged error.

Source

Thrown at packages/@uppy/core/src/companion-client/Provider.ts:126

  #getPlugin() {
    const plugin = this.uppy.getPlugin(this.pluginId) as UnknownProviderPlugin<
      M,
      B
    >
    if (plugin == null) throw new Error('Plugin was nullish')
    return plugin
  }

  /**
   * Ensure we have a preauth token if necessary. Attempts to fetch one if we don't,
   * or rejects if loading one fails.
   */
  async ensurePreAuth(): Promise<void> {
    if (this.companionKeysParams && !this.preAuthToken) {
      await this.fetchPreAuthToken()

      if (!this.preAuthToken) {
        throw new Error(
          'Could not load authentication data required for third-party login. Please try again later.',
        )
      }
    }
  }

  authQuery(data: unknown): Record<string, string> {
    return {}
  }

  authUrl({
    authFormData,
    query,
    authCallbackToken,
  }: {
    authFormData: unknown
    query: Record<string, string>
    authCallbackToken?: string | undefined

View on GitHub (pinned to 5d4dedd02a)

Solutions

  1. Check the browser network tab / Companion logs for the failed pre-auth request and fix the Companion-side issue (credentials, provider secret, companionUrl)
  2. Verify the companionUrl passed to the plugin is reachable and correctly proxied (HTTPS, CORS headers)
  3. Retry login after fixing connectivity — ensurePreAuth runs per login attempt
  4. If you do not need key-based Companion auth, remove companionKeysParams from the plugin options so no pre-auth token is required

Example fix

// before
new GoogleDrive(uppy, {
  companionUrl: 'http://localhost:3020', // wrong/down Companion
  companionKeysParams: { key: '...' },
})

// after
new GoogleDrive(uppy, {
  companionUrl: 'https://companion.example.com', // verified healthy Companion
  companionKeysParams: { key: '...' },
})
Defensive patterns

Strategy: try-catch

Validate before calling

// before login, probe Companion health
await fetch(`${companionUrl}/`, { method: 'HEAD' }).catch(() => {
  throw new Error('Companion unreachable')
})

Type guard

null

Try / catch

try {
  await provider.loginOAuth()
} catch (err) {
  if (err.message.includes('Could not load authentication data')) {
    uppy.info('Login temporarily unavailable, please retry.', 'error', 5000)
  }
}

Prevention

When it happens

Trigger: Calling provider.loginOAuth() (e.g. clicking 'Sign in with Google Drive' in the Dashboard) while the plugin was instantiated with companionKeysParams, and the POST /pre-auth/: Companion request either fails or returns no token. ensurePreAuth then sees this.preAuthToken still falsy and throws.

Common situations: Companion is down, misconfigured, or the client points to a wrong companionUrl; a reverse proxy/CORS rule blocks the pre-auth request; the provider credentials on Companion are invalid so it refuses to mint a token; transient network hiccup during login.

Understand the failure class

Related errors


AI-assisted analysis of transloadit/uppy@5d4dedd02a (2026-08-28). Data as JSON: /api/errors/ed140b513481fedc. Report an issue: GitHub.