Closed AdrianoAla closed 2 years ago
@arpidano
Just reading through this quick. If the error is on check auth there might an an issue with the saved auth file. Can you delete it and try saving it again?
The code looks correct from my point of view.
Thanks
Chuck
@arpidano
Can you please change your login succeed function to this and let me know if it makes any difference
func _on_FirebaseAuth_login_succeeded(_auth) -> void:
_print_to_console("Login with email and password has worked")
Firebase.Auth.save_auth(_auth)
I downloaded the latest version and this code has worked perfect for me, so I am not sure what is going on with your code. Worse comes to worse I may ask you to share you code with me privately so I can look through it, (But I would ask you to scrub all parts that tie into your Firebase so I don't have access.)
Thanks
Chuck
It looks like manual_token_refresh() function has unneeded _base_url in request url.
# Function is called when requesting a manual token refresh
func manual_token_refresh(auth_data):
auth = auth_data
var refresh_token = null
auth = get_clean_keys(auth)
if auth.has("refreshtoken"):
refresh_token = auth.refreshtoken
elif auth.has("refresh_token"):
refresh_token = auth.refresh_token
_needs_refresh = true
_refresh_request_body.refresh_token = refresh_token
request(_base_url + _refresh_request_url, _headers, true, HTTPClient.METHOD_POST, JSON.print(_refresh_request_body))
Modifying last line to request(_refresh_request_url, _headers, true, HTTPClient.METHOD_POST, JSON.print(_refresh_request_body))
fixes the response error and gets refreshed token.
Still, it does not return login_succeeded signal.
My workaround was to connect to token_refresh_succeeded to my _on_FirebaseAuth_login_succeeded function and than disconnect it, so it does not get called when token gets refreshed automaticly.
func _ready():
Firebase.Auth.connect("login_succeeded", self, "_on_FirebaseAuth_login_succeeded")
Firebase.Auth.connect("token_refresh_succeeded", self, "_on_FirebaseAuth_login_succeeded")
# For Testing purpouses sign-in with test account
Firebase.Auth.check_auth_file()
if Firebase.Auth.auth.empty():
Firebase.Auth.login_with_email_and_password("test@test.lv", "testtest")
func _on_FirebaseAuth_login_succeeded(auth):
Firebase.Auth.disconnect("token_refresh_succeeded", self, "_on_FirebaseAuth_login_succeeded")
Firebase.Auth.save_auth(auth)
Good call out! Can you open a PR with these changes? We'll expedite it through, @pukkah.
@Pukkah thanks for finding that. I have merged it into the codebase
Describe the bug save_auth and check_auth dont work, I get the following error when I try to use check_auth
To Reproduce
Expected behavior the autherntication data to be stored and then to be loaded once the program restarts
Environment: