postgrest-rs icon indicating copy to clipboard operation
postgrest-rs copied to clipboard

Add the Authorization header in the README.md examples regarding headers

Open ygouzerh opened this issue 2 years ago • 0 comments
trafficstars

Improve documentation

Link

README.md

Describe the problem

Supabase seems to need the Authorization token as well as the apikey token. It took me some time to realize it. Without that, even the service_role api key doesn't work unfortunately. It could be valuable for other users so they can copy the snippets directly.

I put it as an issue instead of a PR, because I am not sure if it's always the case.

Some discussion regarding the Authorization header: https://github.com/orgs/supabase/discussions/3963

Describe the improvement

Update the snippet to add the insertion of Authorization header in the sections:

  • Simplified example using a custom header (e.g. for API gateway authentication with Supabase).
  • Secure example with authenticated API gateway using the dotenv crate to correctly retrieve sensitive values.

Note: the Authorization header value needs to be on the format Bearer <token-value>:

  • Example:
    .insert_header("Authorization", format!("Bearer {}", token));
    

ygouzerh avatar Oct 08 '23 13:10 ygouzerh