Android Question FirebaseFirestore help.

Oregon

Member
Good afternoon. I'm trying to use a library
FirebaseFirestore. Tell me (preferably with screenshots) how to get a token for work?

1700307612786.png
)
 

Waldemar Lima

Well-Known Member
Licensed User
in Firebase Panel -> FireStore Database -> Rules
Your permissions probably look like this >:
B4X:
rules_version = '2';

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

change to these debug permissions >:
B4X:
rules_version = '2';

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if
          request.time < timestamp.date(2025, 4, 9);
    }
  }
}

From there you will be able to authenticate with the @Alexander Stolte library:
https://www.b4x.com/android/forum/threads/b4x-firebase-auth-rest-api.119935/#content

B4X:
Wait For (fa_rest.signInEmailPW(TextField1.Text,TextField2.Text,True)) complete (root As Map)

    If root.Get("success") = True Then      
   
        Dim mytoken as String = root.Get("idToken") 'YOU NEED THIS TOKEN'
        For Each k As String In root.Keys
            Log("Key: " & k & CRLF & "Value: " & root.Get(k))
        Next      
       
        Store.Initialize("Firestore",Me,mytoken,"(default)","wiki-fan-47nnd92")
       
    Else
        Log("ErrorCode: " & fa_rest.getErrorCode(root))
        Log("ErrorMessage: " & fa_rest.getErrorMessage(root))
        Log("Reason: " & fa_rest.getErrorMap(root).Get("reason"))
        Log("Domain: " & fa_rest.getErrorMap(root).Get("domain"))
        Log("Message: " & fa_rest.getErrorMap(root).Get("message"))
    End If
 
Upvote 1
Top