Closed BnewVanZuarez closed 2 years ago
Hi BnewVanZuarez,
What base URL are you using? There are 2 different parameters. One for authentication (auth) and one for the database (rest). Look:
Auth:
$service = new PHPSupabase\Service( "YOUR_API_KEY", "https://aaabbbccc.supabase.co/auth/v1/" );
REST
$service = new PHPSupabase\Service( "YOUR_API_KEY", "https://aaabbbccc.supabase.co/rest/v1/" );
I See, I didn't read the documentation carefully, thank you
I am also having a problem with this. If I understand correctly, the same Service instance must be used for auth and database manipulation, or else the bearer tokens don't match. How do we switch the base URLs for each use?
Hi Alexpi,
Generally you will have a page to do the authentication, and therefore you will create an instance of the service
class using the auth
endpoint. After authenticating, you will save the bearer token
(in the session, for example) and then in the other pages you will create the instance of the service
class according to your needs (generally, using the rest
endpoint).
But anyway, I'll take your suggestion and add the setUrlBase
method in future versions.
Thank you for your contribution
Hi @rafaelwendel,
I did what you describe roughly, and I am getting a 'new row violates row-level security policy for table' 403 error. I guess this is related to the setup of Supabase rules, and not your library. It's the first time I am using Supabase and I have to study more!
Thanks
Hi Alexpi,
You're right. The RLS (Row Level Security) is controlled by Supabase itself, according to the rules that you create within your own project.
Read more at: https://subase.com/docs/guides/auth/row-level-security
Thank you for building this library! When I try to use
$db = $service->initializeDatabase('categories', 'id');
$newCategory = ['categoryname' => 'ibnuraffy@duck.com'];
$data = $db->insert($newCategory);
I get the error
Client error: 'POST https://MY_URL_PROJECT.supabase.co/auth/v1/categories' resulted in a '404 Not Found' response: 404 page not found
Do you have any suggestion what might cause this?