ahsankhatri / firestore-php

Firestore PHP Client (without gRPC extension)
MIT License
62 stars 57 forks source link

Laravel 7 Authentication Issue #24

Open MikeCraig418 opened 4 years ago

MikeCraig418 commented 4 years ago

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.

rafaelvaloto commented 4 years ago

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