I am new to Firebase, right now i want to try Firestore php SDK and implement firestore auth rule. Current code below is work fine
use Google\Cloud\Firestore\FirestoreClient;
$db = new FirestoreClient();
$db->collection('mycollectionname')
->document('mydocumentname')
->set(['name'=>'aaa','value'=>'111');
Firestore auth rule
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
// before change
allow read, write: if true;
// after change
allow read, write: if request.auth.uid != null;
}
}
}
After change true to request.auth.uid != null, its give me error:
{ "error": { "code": 403, "message": "Missing or insufficient permissions.", "status": "PERMISSION_DENIED" } }
I can figure out to get user data like : email & password or user id token, how to solve above error using user data?