cli icon indicating copy to clipboard operation
cli copied to clipboard

Unexpected error retrieving remote project status: {"message":"Unauthorized"}

Open swag-cl opened this issue 1 year ago โ€ข 4 comments

๐Ÿ› Supabase CLI Bug Report - Authorization Error

Date: September 9, 2025
CLI Version: Tested on v2.39.2 and v2.40.7
OS: Windows 11
Project ID: cpxx Sent crash report: e70bd6b3b7544a4881e67f76fd541c89


๐Ÿšจ Issue Summary

Problem: CLI command supabase link --project-ref cpxx consistently returns {"message":"Unauthorized"} despite valid access token and successful API access.

Expected: Successful project linking
Actual: Authorization failure on CLI, while direct API calls work perfectly


๐Ÿ” Detailed Description

Symptoms

  1. โŒ supabase link --project-ref cpxx โ†’ "Unauthorized"
  2. โŒ supabase db pull --linked โ†’ "Unauthorized"
  3. โœ… supabase login --token xxx โ†’ Success
  4. โœ… supabase projects list โ†’ Shows both projects
  5. โœ… Direct API calls work perfectly

Environment

  • OS: Windows 11 x64
  • CLI Installation: Scoop package manager
  • Versions Tested: 2.39.2 โ†’ 2.40.7 (both fail)
  • Token Type: Personal Access Token (sbp_...)
  • Organization: osxx
  • Region: us-east-2

๐Ÿงช Reproduction Steps

Setup

# Install/Update CLI
scoop install supabase
scoop update supabase  # v2.40.7

# Login (SUCCESS)
supabase login --token sbp_57xx
# Output: "You are now logged in. Happy coding!"

# List projects (SUCCESS)
supabase projects list
# Shows project correctly  | cpxx

Failing Command

# This consistently fails
supabase link --project-ref cpxx
# Error: Unexpected error retrieving remote project status: {"message":"Unauthorized"}

# Debug output shows:
supabase link --project-ref cpxx --debug
# Supabase CLI 2.40.7
# Loading project ref from flag: cpxx
# Using access token from env var...
# HTTP GET: https://api.supabase.com/v1/projects/cpxx
# Unexpected error retrieving remote project status: {"message":"Unauthorized"}

Working API Calls

# Direct API access works perfectly
curl -H "Authorization: Bearer sbp_57xx" \
  https://api.supabase.com/v1/projects/cpxx
# Returns valid project data

curl -H "Authorization: Bearer sbp_57xx" \
  https://api.supabase.com/v1/projects
# Returns array with both projects including cpxx

๐Ÿ”ง Troubleshooting Attempted

What We Tried

  1. โœ… Updated CLI: v2.39.2 โ†’ v2.40.7 (same error)
  2. โœ… Re-login multiple times: Always succeeds
  3. โœ… Fresh project init: supabase init โ†’ clean start
  4. โœ… Verified token permissions: Works with direct API
  5. โœ… Different flag combinations: --password, --debug
  6. โœ… Network connectivity: API calls successful

What Works

  • โœ… supabase login --token xxx
  • โœ… supabase projects list
  • โœ… supabase status (local)
  • โœ… supabase start (local)
  • โœ… Direct curl API calls

What Fails

  • โŒ supabase link --project-ref xxx
  • โŒ supabase db pull --linked
  • โŒ Any command requiring project linking

swag-cl avatar Sep 09 '25 20:09 swag-cl

Same issue.

winkelmeyer avatar Jan 06 '26 16:01 winkelmeyer

Hi, I'm just doing a clean up of issues, Did you manage to get this one working in the end?

Hallidayo avatar Apr 01 '26 15:04 Hallidayo

Just got this issue recently what worked for me was;

unset SUPABASE_ACCESS_TOKEN

Then check if it's been removed with

echo $SUPABASE_ACCESS_TOKEN

Then just log back in with supabase login which prompted me to re-authenticated with the web browser this time which solved the issue so seem'd like a stale token problem.

TomAtterton avatar Apr 10 '26 19:04 TomAtterton

Hi! Thanks for opening this issue.

We're closing this because it has not had any activity for 45 days, and we try to keep the Supabase CLI issue tracker focused on reports that are still current.

If this still reproduces on the latest Supabase CLI, please comment with /reopen on its own line and include your CLI version, updated reproduction steps, and any recent error output. We appreciate the signal and are happy to take another look.

github-actions[bot] avatar Jun 17 '26 18:06 github-actions[bot]