H hanyelmehy Well-Known Member Licensed User Longtime User Mar 28, 2020 #1 i use this code to get data from firebase database B4X: Copy 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: Copy 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
i use this code to get data from firebase database B4X: Copy 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: Copy 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
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2020 #2 hanyelmehy said: job1.Initialize("FiBaDb_read", Me) Click to expand... 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? Upvote 0
hanyelmehy said: job1.Initialize("FiBaDb_read", Me) Click to expand... 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?
H hanyelmehy Well-Known Member Licensed User Longtime User Mar 29, 2020 #3 Erel said: 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? Click to expand... 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: Mar 29, 2020 Upvote 0
Erel said: 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? Click to expand... 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
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2020 #4 Check the token value. Maybe it is empty. Upvote 0
H hanyelmehy Well-Known Member Licensed User Longtime User Mar 29, 2020 #5 Erel said: Check the token value. Maybe it is empty. Click to expand... I already checked it every time, it's not empty Upvote 0
Erel said: Check the token value. Maybe it is empty. Click to expand... I already checked it every time, it's not empty
Erel B4X founder Staff member Licensed User Longtime User Mar 30, 2020 #6 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 ? Upvote 0
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 ?
H hanyelmehy Well-Known Member Licensed User Longtime User Mar 30, 2020 #7 Erel said: 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 ? Click to expand... 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
Erel said: 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 ? Click to expand... 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,
Erel B4X founder Staff member Licensed User Longtime User Mar 31, 2020 #8 401 status code usually means that you are not allowed to access the given URL. Maybe you need to supply username and password. Upvote 0
401 status code usually means that you are not allowed to access the given URL. Maybe you need to supply username and password.
H hanyelmehy Well-Known Member Licensed User Longtime User Mar 31, 2020 #9 Erel said: 401 status code usually means that you are not allowed to access the given URL. Maybe you need to supply username and password. Click to expand... 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
Erel said: 401 status code usually means that you are not allowed to access the given URL. Maybe you need to supply username and password. Click to expand... 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)