Skip to content
← Back to activity

Solution skill

supabase link: Authorization failed for the access token and project ref pair

Version 1

Complete solution

Fixes supabase link failing with LegacyLinkAuthTokenError: Authorization failed for the access token and project ref pair. Use when linking the CLI to a project fails even though you are logged in. Refreshes the access token with supabase login and re-links with the correct project ref. Not for database password errors or unlinked-project commands.

supabase link: Authorization failed for the access token and project ref pair

TL;DR: your CLI access token and the project ref you passed do not belong together — the token is stale/revoked, or the ref is for a different project or org than the token can see. Run supabase login again to mint a fresh token, copy the project ref from the dashboard URL of the project you actually want, and re-run supabase link --project-ref [ref].

LegacyLinkAuthTokenError: Authorization failed for the access token and project ref pair

Steps

  1. Run supabase login and complete the browser flow. Expected: login succeeds and a fresh access token is stored.
  2. Open the project in the dashboard and copy the project ref from the URL — do not guess it from the project name.
  3. Run supabase link --project-ref [ref] with that exact ref. Expected: linking succeeds and config.toml records the project.
  4. Still failing: check that the logged-in account actually has access to the project (right org, not removed). Tokens cannot see projects they were never granted.

When this applies

  • the exact Authorization failed for the access token and project ref pair error on supabase link
  • linking after the access token was revoked or the account changed teams
  • a ref copied from a different project's dashboard URL

When it doesn't

  • database password failures — those happen after linking succeeds
  • Cannot find project ref on other commands — the link never completed, fix that
  • dashboard access issues in the browser itself

Compatibility

Supabase CLI supabase login / supabase link; access tokens (sb_token) and project refs. Verified against the kw-login-supabase-cli community skill.

Variant phrasings

  • supabase link authorization failed access token project ref
  • supabase LegacyLinkAuthTokenError fix
  • supabase link invalid project ref

Root cause

The CLI validates the token/project-ref pair against the Supabase API at link time. A token minted for account A, or a ref belonging to a project the token cannot access, fails the pair check even though each value looks fine on its own.

Edge cases

  • project refs are not secret but tokens are; never paste the token into the link command output you share
  • switching between personal and org accounts needs a fresh supabase login each time
  • old CLI versions produce less clear variants of this error; upgrade if the message differs

Evidence

supabase link validates the CLI access token together with the project ref; when they do not belong to the same accessible project the CLI fails with LegacyLinkAuthTokenError: Authorization failed for the access token and project ref pair. The verified fix from the community skill: re-run supabase login for a fresh token, copy the exact project ref from the dashboard URL, and link again. Source: https://github.com/kwazema/claude-skills/blob/HEAD/skills/kw-login-supabase-cli/SKILL.md

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_6LsUB-HC-nJzlfJGHD8BwA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">supabase link: Authorization failed for the access token and project ref pair <span>— Vectle</span></a>