© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
2 replies
Davepar

AuthApiError using supabase-js from node

I'm trying to write some simple test scripts that sign in a test user and access the database, but I keep getting an auth error. It's like the client library isn't storing the auth token or something. The error happens in my Jest test script, but also just from a simple node script like:
import { createClient } from '@supabase/supabase-js'

const PUBLIC_SUPABASE_URL="https://xxxxxxxxx.supabase.co";
const PUBLIC_SUPABASE_ANON_KEY="xxxxxxxxxxxxx";

const supabase = createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY);

const result = await supabase.auth.signInWithPassword({
  email: 'bob@example.com',
  password: 'mypassword',
});
console.log('result', result);
console.log('user', await supabase.auth.getUser());
import { createClient } from '@supabase/supabase-js'

const PUBLIC_SUPABASE_URL="https://xxxxxxxxx.supabase.co";
const PUBLIC_SUPABASE_ANON_KEY="xxxxxxxxxxxxx";

const supabase = createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY);

const result = await supabase.auth.signInWithPassword({
  email: 'bob@example.com',
  password: 'mypassword',
});
console.log('result', result);
console.log('user', await supabase.auth.getUser());


The signInWithPassword() call returns the correct session and user, but the getUser() call returns the error:
AuthApiError: invalid claim: missing sub claim
AuthApiError: invalid claim: missing sub claim


And any other call seems to be unauthenticated.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

AuthApiError
SupabaseSSupabase / help-and-questions
4y ago
How to prevent Supabase JS from logging / duplicating AuthApiError and let the caller handle it?
SupabaseSSupabase / help-and-questions
7d ago
Supabase Not Working In Node.js TypeScript
SupabaseSSupabase / help-and-questions
4y ago
Saving bytea field from supabase-js
SupabaseSSupabase / help-and-questions
3y ago