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());


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

And any other call seems to be unauthenticated.
Was this page helpful?