Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jantznick opened this issue Sep 10, 2023 · 0 comments · Fixed by #315
Closed

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

jantznick opened this issue Sep 10, 2023 · 0 comments · Fixed by #315
Labels
bug Something isn't working

Comments

@jantznick
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant