Closed eydun closed 2 years ago
hello eydun,
Could you put all your code here? So I can try to help you.
In my project, the following code works correctly
PS: Make sure the URL is correct when instantiating the $service
variable: https://YOUR_URL_PROJECT.supabase.co/auth/v1/
<?php
require 'vendor/autoload.php';
$service = new PHPSupabase\Service(
"MY_API_KEY",
"https://MY_URL_PROJECT.supabase.co/auth/v1/"
);
$auth = $service->createAuth();
try{
$auth->signInWithEmailAndPassword('useremail@email.com', 'SomePassWord');
$data = $auth->data(); // get the returned data generated by request
if(isset($data->access_token)){
$userData = $data->user; //get the user data
echo 'Login successfully for user ' . $userData->email;
//save the $data->acess_token in Session, Cookie or other for future requests.
}
}
catch(Exception $e){
echo $auth->getError();
}
Thanks for the prompt reply!
I missed /auth/v1/
from the url. Now it works! 😊
😃
Anyone still facing issues can use /rest/v1 instead of /auth/v1/
Thanks for the prompt reply!
I missed
/auth/v1/
from the url. Now it works! blush
Hello gakenge. What problem are you facing?
Hello, for me I was using the /auth/v1 route according to your documentation to query the supabase rest API but I kept getting a 404 error so I switched it to /rest/v1 and the package worked well.
Thank you for building this library!
When I try to use
$auth->signInWithEmailAndPassword
I get the errorno Route matched with those values
.Do you have any suggestion what might cause this?