firestore-php icon indicating copy to clipboard operation
firestore-php copied to clipboard

Laravel 7 Authentication Issue

Open MikeCraig418 opened this issue 5 years ago • 1 comments

Hello --

What am I missing here:

        $firestoreClient = new FirestoreClient('test-project-123', 'AIzXXXXX', [
            'database' => '(default)',
        ]);

        $collections = $firestoreClient->listDocuments('test', [
            'pageSize' => 1,
            'pageToken' => 'nextpagetoken'
        ]);
MrShan0\PHPFirestore\Exceptions\Client\Forbidden 

  You do not have permission to access the requested resource.  Response: {
  "error": {
    "code": 403,
    "message": "Missing or insufficient permissions.",
    "status": "PERMISSION_DENIED"
  }
}

I checked my API keys, everything looks good.

MikeCraig418 avatar Jun 28 '20 16:06 MikeCraig418

hello @949mac , check if your database uses authentication in the firestore database rule .. you could use something like this, if your base uses email / password authentication

$firestoreClient = new FirestoreClient('projectId', 'apiKey', [ 'database' => '(default)', ]); $auth = new FirestoreAuthentication($firestoreClient); $auth->signInEmailPassword('email', 'password');

I hope I helped you

rafaelvaloto avatar Jul 25 '20 01:07 rafaelvaloto