rafaelwendel / phpsupabase

PHP Client to use Supabase
MIT License
187 stars 18 forks source link

no Route matched with those values #2

Closed eydun closed 2 years ago

eydun commented 2 years ago

Thank you for building this library!

When I try to use $auth->signInWithEmailAndPassword I get the error no Route matched with those values.

Do you have any suggestion what might cause this?

rafaelwendel commented 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();
}
eydun commented 2 years ago

Thanks for the prompt reply!

I missed /auth/v1/ from the url. Now it works! 😊

rafaelwendel commented 2 years ago

😃

gakenge commented 1 year ago

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

rafaelwendel commented 1 year ago

Hello gakenge. What problem are you facing?

gakenge commented 1 year ago

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.