Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

get_user calls fail when no session or jwt is available #314

@jantznick

Description

@jantznick

Bug report

Describe the bug

Currently when making a call to get_user without a jwt or valid session the http response is giving an error:

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gotrue/_sync/gotrue_base_api.py", line 113, in _request
    response.raise_for_status()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://dwmniiddtelocakrnzer.supabase.co/auth/v1/user'
For more information check: https://httpstatuses.com/401

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/nick/repos/supabase-error/main.py", line 11, in <module>
    print(supabase.auth.get_user())
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gotrue/_sync/gotrue_client.py", line 385, in get_user
    return self._request("GET", "user", jwt=jwt, xform=parse_user_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gotrue/_sync/gotrue_base_api.py", line 118, in _request
    raise handle_exception(e)
gotrue.errors.AuthApiError: invalid claim: missing sub claim

To Reproduce

import os
from supabase import create_client, Client

url: str = os.environ.get("SUPABASE_URL")
key: str = os.environ.get("SUPABASE_KEY")
supabase: Client = create_client(url, key)

supabase.auth.get_user()

Expected behavior

Expecting some sort of no user found message

System information

MacOS

Additional context

I also see in some issues around this on the JS library that you need to mark the option of persistent sessions as false when creating the client. I tried doing that and it didn't seem to prevent the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions