Missing or insufficient permissions

Currently I’ve set firebase for android and iOS in a KMM project.
I’ve added firebase sdk on both projects for the native part to configure them.

On the shared side, I’m using gitlive firebase sdk library, where I do a query to firestore database. So the logic to query data is SHARED

Here’s the query:

    @OptIn(ExperimentalCoroutinesApi::class)
    override fun invoke(): Flow<List<TicketUi>> = flow {
        val list =  Firebase.firestore
            .collection("users")
            .document(Firebase.auth.currentUser!!.uid)
            .collection("receipts")
            .snapshots
            .mapLatest {
                it.documents.map { doc ->
                    // Additional code converting the document to a Receipt
                }
            }

        // Collect the flow and emit the list
        list.collect { ticketUiList ->
            emit(ticketUiList)
        }
    }.catch { error ->
        Logger.e { "Error in GetAllTicketsUseCaseImpl.invoke(): ${error.cause} && message: ${error.message}" }
        emit(emptyList<TicketUi>())
    }

I’ve set up the emulator in order to test it on both platforms.

Android
It works perfectly, all good

iOS:

  • I’ve created a iOS project on Firebase
  • GoogleServices-Info.plist has been added to the project
  • I’ve added Firebase SDK to the project, that includes Auth & Firestore.
  • On AppDelegate I call the following code
        FirebaseApp.configure()
        
        // Firestore Configuration
        let settings = Firestore.firestore().settings
        settings.host = "127.0.0.1:8080"
        settings.cacheSettings = MemoryCacheSettings()
        settings.isSSLEnabled = false
        Firestore.firestore().settings = settings
        FirebaseConfiguration.shared.setLoggerLevel(.debug)
        
        Auth.auth().useEmulator(withHost:"127.0.0.1", port:8081)
        let auth = Auth.auth()
        
         if auth.currentUser == nil {
             // Sign in anonymously
             auth.signInAnonymously { authResult, error in
                 if let error = error {
                     // Sign-in failed∂
                     print("signInAnonymously:failure (error.localizedDescription)")
                 } else {
                     // Sign-in succeeded
                     print("signInAnonymously:success")
                     if let user = authResult?.user {
                         print("User: (user.uid)")
                     }
                 }
             }
         } else {
             // Already signed in
             print("Already logged in: (auth.currentUser?.uid ?? "No UID")")
         }

Cool. Time to query the data from firestore for that specific user. The following error shows up:

Error Domain=FIRFirestoreErrorDomain Code=7 “Missing or insufficient
permissions.” UserInfo={NSLocalizedDescription=Missing or insufficient
permissions.

11.1.0 – [FirebaseFirestore][I-FST000001] Listen for query at users/9hYte9W9Sf1FlH6vMJdnVs0qPNLd/receipts failed: Missing or insufficient permissions.

Here is the rule for firestore emulator

rules_version = '2';

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

I don’t understand what I could be missing, it must be something wrong on the iOS side as on Android I’m able to listen to the query without any issue and retrieve the data.

Is there anything that I might have missed? Or a way to obtain more data on what’s exactly wrong?

2

Found the root cause, it looks like it comes from the kotlin gitlive-firebase library…. Remove this.

Firebase.firestore.settings = firestoreSettings {
        }

Will probably ask in their github project why this happens.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật