GodotNuts / GodotFirebase

Implementations of Firebase for Godot using GDScript
MIT License
530 stars 76 forks source link

Facebook auth failed #339

Closed M77mdsD closed 3 months ago

M77mdsD commented 1 year ago

Describe the bug Trying to use Firebase.Auth.get_auth_localhost(Firebase.Auth.get_FacebookProvider()) to login using Facebook but it doesn't work.

Expected behavior Firebase.Auth.get_auth_localhost(Firebase.Auth.get_FacebookProvider()) Should open a working page to login (this part works) but after that, I get redirected to http://localhost:5000/ with the error "localhost refused to connect." Also, sometimes it works but I get an error message in Godot.

Screenshots bandicam 2023-05-16 01-31-15-565 bandicam 2023-05-16 02-54-59-114

Environment:

Additional context The login screen opens but after that, the redirect link doesn't work (the profile doesn't get registered in The Firebase users). Did I miss a setting somewhere?

fenix-hub commented 1 year ago

Hi, thank you for reaching out. Could you please share your Firebase and Facebook OAuth2 configurations? Blur out all the client_id and client_secrets, I just would like to see if everything is correct both in the GodotFirebase .env file and your Facebook application. If you need send it in private in Discord.

fenix-hub commented 1 year ago

Ignore the previous message, inspecting the screenshot looks like everything should be configured fine. Could you set a breakpoint on line 291 and share the auth variable content? Otherwise just print it before line 291, though a breakpoint could be more useufl.

M77mdsD commented 1 year ago

I printed auth before the breakpoint and it is an empty dictionary. To make it clear, logging in using Google works fine. This issue happens only with Facebook login.

fenix-hub commented 1 year ago

Oh so that's why. I'm expecting auth to not be empty since it should contain the Facebook access token. Could you please put a breakpoint here L403 and check the content of the json result?

M77mdsD commented 1 year ago

I putted a breakpoint in L400 and a response_code = 400 and the json results was an error:

"message": Invalid verification code format.
"type": OAuthException.
"code": 100.
"fbtrace_id": As#####################.
fenix-hub commented 1 year ago

I'm testing and cannot reproduce the error. Are you sure you are running using the version on main branch? Are the facebook id and secret the correct ones?

M77mdsD commented 1 year ago

Yeah, can it be something in the Facebook app itself? Is there somewhere that shows how to set up the Facebook app page? Should I use a test app or a normal app?

fenix-hub commented 1 year ago

We don't have our "official" guide yet, but basically you can just follow this article since 99% of the stuff that should be configured is not specifically related to our plugin, but general Firebase and OAuth2 flow. 👉 guide The only thing you need to do in your project is to set up the facebook_id and facebook_secret in your godot-firebase/.env file like this

[firebase/environment_variables]
apiKey="xxx"
authDomain="xxx"
databaseURL="xxx"
projectId="xxx"
...

[firebase/auth_providers]
facebook_id="xxx"
facebook_secret="xxx"

And everything should just work fine. Of course feel free to reach us out on discord to get some help.

phil-hudson commented 1 year ago

Instead of hitting localhost, what happens if you change it to 127.0.0.1?

I'm having issues where my firebase emulator cannot be resolved from godot, and changing the GodotFirebase code from localhost to 127.0.0.1 made it work for me.

fenix-hub commented 1 year ago

Instead of hitting localhost, what happens if you change it to 127.0.0.1?

I'm having issues where my firebase emulator cannot be resolved from godot, and changing the GodotFirebase code from localhost to 127.0.0.1 made it work for me.

If it works for you, that's ok. There's should me no issue about changing from localhost to 127.0.0.1. Eventually your hosts file doesn't map 127.0.0.1 to localhost, or Godot is unable to resolve it.

phil-hudson commented 1 year ago

Correct, it needs to be mapped in hosts correctly. I just wondered if the user might be having the same issue.

fenix-hub commented 1 year ago

Correct, it needs to be mapped in hosts correctly. I just wondered if the user might be having the same issue.

As it happened for you, there might be a chance a user may have the same issue, even if very low.

WolfgangSenff commented 3 months ago

There's something much bigger here. The entire OAuth2 flow is fully broken now due to deprecations on the Firebase side, removing the loopback URLs in addition to the original URL style. I'm actually going to close this, and when I have a moment, open an entirely new bug to track the issue.