iOS Question Firebase REST API Data

hanyelmehy

Active Member
Licensed User
i use this code to get data from firebase database
B4X:
    Dim job1 As HttpJob
    job1.Initialize("FiBaDb_read", Me)
    job1.Tag = strJobTag
    job1.Download(strFiBaDbRoot & strPath & ".json"  & "?auth=" & Main.strFirebaseSignedInUserToken)

this work with android with B4I i get this error
ResponseError: unknown error, status code: 401

i get token with this code
B4X:
Private Sub GetTokenfn As String
    Dim no As NativeObject
    Dim token As NativeObject = no.Initialize("FIRInstanceID").RunMethod("instanceID", Null).RunMethod("token", Null)
    If token.IsInitialized Then Return token.AsString Else Return ""
End Sub
 

hanyelmehy

Active Member
Licensed User
Always set the job name to an empty string and use Wait For to handle the response.
Never set Job.Tag. These are things that are no longer needed.

Can you post the B4A code that works?
Can you post the B4A code that works? it's the same code
only difference GetToken method
Notes
-I think receive a 401 HTTP status code, mean Server key is not valid
-I am able to use and test firebaseauth with same ios project
 
Last edited:
Upvote 0

hanyelmehy

Active Member
Licensed User
You need to tell us what you are actually doing.
Are you trying to implement this: https://www.b4x.com/android/forum/t...rification-for-signed-in-users.68672/#content ?
app let a user log in with firebase auth, then it will connect to a realtime database with REST API
Notes :
-to use realtime database with REST API you need token
-now I connect using same ios app with realtime database using database secret (this is like a fixed token, the problem is this method well deprecated)
-the problem as I explained before is token,firebase refuse token with 401 HTTP status code,
 
Upvote 0

hanyelmehy

Active Member
Licensed User
401 status code usually means that you are not allowed to access the given URL. Maybe you need to supply username and password.
in firebase according to their documentation :
401 HTTP status code, mean Server key is not valid.
Notes :
-REST API just need token (no username or password)
-as I explained (I connect using same ios app code with realtime database using database secret (this is like a fixed token, the problem in this method it well well deprecated)
 
Upvote 0
Top