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

IMPORTANT: Need to pass BOTH apikey and Authorization headers! #29

Open
princefishthrower opened this issue Feb 22, 2023 · 5 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@princefishthrower
Copy link

princefishthrower commented Feb 22, 2023

Just wasted approx 5 hours when I realized you need to pass both an apikey AND Authorization key when initializing the client:

client := postgrest.NewClient(os.Getenv("SUPABASE_REST_URL"), "public", map[string]string{"apikey": os.Getenv("SUPABASE_SERVICE_KEY"), "Authorization": "Bearer " + os.Getenv("SUPABASE_SERVICE_KEY")})

IMO opinion this should anyway become a single field call 'key' or something, and then within the library itself it is applied to

Hoping this helps anyone who probably otherwise assumed (like I did) that this library was broken!

Please update the README to reflect this information!

@princefishthrower princefishthrower added the bug Something isn't working label Feb 22, 2023
@muratmirgun muratmirgun added the good first issue Good for newcomers label Feb 23, 2023
@muratmirgun
Copy link
Member

Thanks for opening your first issue here! 🎉
I'm looking to inspect and correct

@craigpastro
Copy link

There is the TokenAuth method on the client that will add both the bearer token and the apikey. But, actually, this is a bit strange isn't it? Is this supposed to be a generic PostgREST client? Then I wouldn't expect that invoking TokenAuth would also set the apikey header. I had a look at the JS and Rust clients and they do not set that header.

@zoogeny
Copy link

zoogeny commented Sep 19, 2023

@craigpastro I created a separate issue (#32) which I think addresses your comment. Being able to independently set the Authorization and apiKey headers would be useful for Row Level Security purposes.

@craigpastro
Copy link

@zoogeny Yeah, that is perfect. Thanks for that 🙌

@whoiscarlo
Copy link
Contributor

hey @craigpastro I just I created a PR #41 to help fix this 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 good first issue Good for newcomers
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

5 participants