Skip to content

Error importing ClientOptions from supabase #682

@dantheman0207

Description

@dantheman0207

Describe the bug
I get this error: ImportError: cannot import name 'ClientOptions' from 'supabase'

To Reproduce
This is my code:

from supabase import create_client, Client, ClientOptions
from .config import Settings

settings = Settings()

def get_supabase(jwt: str = None) -> Client:
    if jwt:
        return create_client(
            settings.SUPABASE_URL,
            settings.SUPABASE_KEY,
            options=ClientOptions(
                headers={"Authorization": f"Bearer {jwt}"}
            )
        )
    else:
        return create_client(settings.SUPABASE_URL, settings.SUPABASE_KEY)

Expected behavior
This is using the exact code described in the docs. You can see a screenshot of it below. This import should work as documented.

Screenshots
Screenshot 2024-02-04 at 15 09 09

Desktop (please complete the following information):

  • OS: macOS Sonoma 14.2.1
  • Browser: Safari
  • Version:
    • supabase==2.3.4
    • Python 3.11.7
    • Using virtualenv

Additional context
I am trying to set the header to the user's JWT auth token so I can implement RLS policies, as this will prevent me from writing a bunch of backend code to authorize access.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions