firestore emulator request with error code (permission-denied) and message ("The caller does not have permission to execute the specified operation.").

29 views
Skip to first unread message

roshan chemjong

unread,
Sep 11, 2024, 5:47:58 PMSep 11
to Firebase Google Group
firestore.rules:
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2024, 12, 22);
    }
  }
}

projectName-local-server
firebase.json (firestore): 
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"emulators": {
"auth": {
"port": 9099
},
"functions": {
"port": 5001
},
"firestore": {
"port": 8080
},
"storage": {
"port": 9199
},
"ui": {
"enabled": true
},
"singleProjectMode": true
}


projectName
on main() I've these methods for emulators
WidgetsFlutterBinding.ensureInitialized();

// No dependencies with anything that needs to be initialized.
await Firebase.initializeApp(options: firebaseOptions);
configureDependencies();

// await getIt<FirebaseAppCheck>().setTokenAutoRefreshEnabled(false);

FlutterError.onError = (errorDetails) {
FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails);
};

await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);

PlatformDispatcher.instance.onError = (error, stack) {
FirebaseCrashlytics.instance.recordError(error, stack);
return true;
};

final remoteConfig = getIt<FirebaseRemoteConfig>();

await remoteConfig.setConfigSettings(RemoteConfigSettings(
fetchTimeout: const Duration(minutes: 1),
minimumFetchInterval: const Duration(hours: 1)));

getIt<FirebaseFirestore>().settings = const Settings(
sslEnabled: false,
persistenceEnabled: false,
);

// emulator connection
getIt<FirebaseFirestore>().useFirestoreEmulator("localhost", 8080);
getIt<FirebaseAuth>().useAuthEmulator("localhost", 9099);
getIt<FirebaseStorage>().useStorageEmulator("localhost", 9199);
getIt<FirebaseFunctions>().useFunctionsEmulator("localhost", 5001);

remoteConfig.setDefaults(const {
'greeting_message': 'Hello',
});

runApp(builder());
}


while signing up, Auth emulator ui updates with a new user but at the same time user creation on Firestore request response with code "permission-denied" and above mentioned message. 
All the emulators are working fine except this Firestore, 

Thank you for the help.
Reply all
Reply to author
Forward
0 new messages