Skip to content

Clients should take an optional supabase_token (workaround provided) #658

@turian

Description

@turian

Is your feature request related to a problem? Please describe.

I have a serverless application, using just supabase as the backend. (No flask, fastapi, etc.)

I'm writing a CLI client in Python. The only way I can figure out how to auth the user, is to put my access_token into the client using environment variables. (This is because the CLI might run on a remote machine with no browser.) However, getting the supabase client to accept the access_token is difficult, because it uses supabase_key as both the apikey AND bearer token.

Describe the solution you'd like

    def __init__(
        self,
        supabase_url: str,
        supabase_key: str,
        supabase_access_token: Optional[str] = None,
        options: ClientOptions = ClientOptions(),
    ):
        if supabase_access_token is None:
            supabase_access_token = supabase_key

and use supabase_access_token when constructing headers.

Describe alternatives you've considered

    supabase.postgrest.auth(SUPABASE_PRIVATE_TOKEN)

works but is very janky and undocumented.

Additional context
Appears related to #221, #616, #645

This suggests that it is a commonplace issue.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions