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

Running .rpc() results in missing API key #24

Closed
kay-es opened this issue May 17, 2021 · 4 comments
Closed

Running .rpc() results in missing API key #24

kay-es opened this issue May 17, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@kay-es
Copy link

kay-es commented May 17, 2021

Bug report

Describe the bug

Running the .rpc() method to call a stored procedure ends up with a response containing the following message:
No API key found in request

Using .table() with works fine.

Additional context

I'm not sure if this is a bug or if i miss a place passing the required api key but according to the documentation and looking into the code, there is no place where i should pass a key additionally to the supabase_key

@kay-es kay-es added the bug Something isn't working label May 17, 2021
@kay-es
Copy link
Author

kay-es commented May 17, 2021

Found the solution: To run a query via the httpx client successfully, we need to add an additional apikey header with the supabase key as value. You could fix that within the auth method in the PostgrestClient class.

Workaround manipulating the session headers:

supabase.postgrest.session.headers["apikey"] = supabase.postgrest.session.headers["Authorization"][7:]
result = await supabase.rpc('<PROCEDURE>', { "key": value})

@kay-es kay-es closed this as completed May 17, 2021
@cacosandon
Copy link

cacosandon commented Apr 28, 2023

thanks @kay-es! I think we should re-open this issue. still happening on new versions.

@akarshghale
Copy link

thanks @kay-es! I think we should re-open this issue. still happening on new versions.

Hi, yes this issue still happening.

@anand2312
Copy link
Contributor

anand2312 commented Oct 14, 2023

This is because the PostgREST server itself doesn't expect this header, but supabase does. As postgrest-py is supposed to work with any generic postgREST server (and not only with supabase) we do not set the apiKey header here. If you use the https://github.com/supabase-community/supabase-py library (that uses this library under the hood) it sets the header for you correctly.

Edit: i read wrong, i thought this was on the postgrest-py repo

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

No branches or pull requests

4 participants