firestore-php
firestore-php copied to clipboard
Laravel 7 Authentication Issue
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.
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