Skip to content

Support new Supabase API key format#36

Open
sankar4n wants to merge 3 commits intosupabase-community:devfrom
sankar4n:dev
Open

Support new Supabase API key format#36
sankar4n wants to merge 3 commits intosupabase-community:devfrom
sankar4n:dev

Conversation

@sankar4n
Copy link
Copy Markdown

This pull request updates the way HTTP headers are set for authentication in the NewClient function to correctly support both legacy JWT tokens and new-style Supabase API keys. It also adds comprehensive tests to verify the new behavior.

Authentication header handling:

  • Updated NewClient in client.go to set the Authorization header differently based on the token type: new-style Supabase API keys (those starting with sb_) are now sent as-is (without a Bearer prefix), while legacy JWT tokens continue to use the Bearer scheme. The apikey header is always set to the raw token. This ensures compatibility with Supabase's evolving authentication requirements.

Testing:

  • Added a new test TestNewClientHeaders in client_test.go to verify that both apikey and Authorization headers are set correctly for different token formats, covering legacy JWTs, new publishable/secret keys, and the empty token case.

Dependency update:

  • Imported the strings package in client.go to facilitate token prefix checking.

Copilot AI and others added 3 commits March 13, 2026 14:46
Co-authored-by: sankar4n <501259+sankar4n@users.noreply.github.com>
…-key-changes

Support new Supabase API key format (sb_publishable / sb_secret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants