Closed mthnzbk closed 1 year ago
same issue here. i can't seem to get my manual one to work correct. it just gives this result.
Error 400: invalid_request
More info: The out-of-band (OOB) flow has been blocked in order to keep users secure. Follow the Out-of-Band (OOB) flow migration guide linked in the developer docs below to migrate your app to an alternative method. Request details: redirect_uri=urn:ietf:wg:oauth:2.0:oob
If you're not wanting mobile users, you can use Firebase.Auth.get_google_auth_localhost()
instead and it should work. it just gives an error page when you finish. i think that they should fix the error page and the google manual thing because i can't seem to get those to work 100% correctly.
Manual authentication has been deprecated by Google and we're working to remove it from our plugin. Will mention it here when that's done.
One thing to note: you can follow the automatic login found here: https://github.com/GodotNuts/GodotFirebase/wiki/Authentication-and-User-Management#login-with-oauth-automatic
And if needed go through the extra OAuth steps found here: https://github.com/GodotNuts/GodotFirebase/wiki/Installation-and-Activation#additional-oauth-configuration
Going to go ahead and close this, since technically it's already handled.
@WolfgangSenff wiki obsolete
Where? Can you point us to exactly where this is still an issue? Because it's been fixed for quite a while.
The information at https://github.com/GodotNuts/GodotFirebase/wiki/Authentication-and-User-Management#login-with-oauth-automatic is deprecated
The information at https://github.com/GodotNuts/GodotFirebase/wiki/Authentication-and-User-Management#login-with-oauth-automatic is deprecated
The script would be:
extends Node
var provider = AuthProvider
var port = 8060
func _ready():
provider = Firebase.Auth.get_GoogleProvider()
Firebase.Auth.connect("login_succeeded", self, "_on_login_succeeded")
Firebase.Auth.connect("login_failed",self, "_on_login_failed")
func _on_login_succeeded(user : Dictionary):
$Label.set_text("Successfully logged in with oAuth2 as: {email}".format({email=user.email}))
func _on_SignInWithGoogle_button_pressed():
$Label.set_text("Exchanging authorization code with a oath token...")
Firebase.Auth.get_auth_localhost(provider, port)
and not what is there in the example.
@WolfgangSenff But a doubt, this works on android?
I'm actually not sure - the list of providers that works does not include Android, which I find to be very odd! @fenix-hub - any clue on this?
@WolfgangSenff I'm here on the desktop, I'm managing to login, but how do I go after it was logged in, automatically log in the next time I open it.
Look at the code you have here:
extends Node
var provider = AuthProvider
var port = 8060
func _ready():
provider = Firebase.Auth.get_GoogleProvider()
var token = Firebase.Auth.get_token_from_url(provider)
# If your project is hosted on `https://<your_site>/<your_app>`
# Firebase.Auth.set_redirect_uri("https://<your_site>/<your_app>.html")
if token == null:
$Label.set_text("You need to login!")
else:
Firebase.Auth.login_with_oauth(token, provider)
Firebase.Auth.connect("login_succeeded", self, "_on_login_succeeded")
Firebase.Auth.connect("login_failed",self, "_on_login_failed")
func _on_login_succeeded(user : Dictionary):
$Label.set_text("Successfully logged in with oAuth2 as: {email}".format({email=user.email}))
func _on_SignInWithGoogle_button_pressed():
$Label.set_text("Exchanging authorization code with a oath token...")
#Firebase.Auth.login_with_oauth(, provider)
#Firebase.Auth.get_auth_with_redirect(provider)
Firebase.Auth.get_auth_localhost(provider, port)
@WolfgangSenff _on_login_succeeded(user : Dictionary) has the user which is a dictionary, ok,. but what value do i use to pass to Firebase.Auth.login_with_oauth(token, provider)
after the user has logged in 1 time, to do the automatic login, I'm trying to use the idtoken, but it gives an error.
see how I'm trying:
extends Node
var provider = AuthProvider
var port = 8060
func _ready():
Firebase.Auth.connect("login_succeeded", self, "_on_login_succeeded")
Firebase.Auth.connect("login_failed",self, "_on_login_failed")
provider = Firebase.Auth.get_GoogleProvider()
_on_application_start()
func _on_login_succeeded(user : Dictionary):
$Label.set_text("Successfully logged in with oAuth2 as: {email}".format({email=user.email}))
Firebase.Auth.save_auth(user)
func _on_SignInWithGoogle_button_pressed():
$Label.set_text("Exchanging authorization code with a oath token...")
#Firebase.Auth.login_with_oauth(, provider)
#Firebase.Auth.get_auth_with_redirect(provider)
Firebase.Auth.get_auth_localhost(provider, port)
func _on_application_start():
Firebase.Auth.load_auth()
var token = Firebase.Auth.auth.idtoken
if token != null:
Firebase.Auth.login_with_oauth(token, provider)
@MiqueiasDevGames if you are on Desktop, login_with_oauth()
is not necessary.
As the wiki mentions
🖥️ If your application will be published only for Desktop users and you don't have a web hosting environment where to redirect users, you can use (a) Firebase.Auth.get_auth_localhost(provider, port) to let OAuth2 flow redirect users directly to a static page provided by our plugin. In this case, the application will listen on localhost:port for the access token coming from your provider OAuth2 flow, and the user will be automatically logged in.
So your login script (both for first login and subsequent logins) can be something like this:
extends Node
var provider = AuthProvider
var port = 8060
func _ready():
Firebase.Auth.connect("login_succeeded", self, "_on_login_succeeded")
Firebase.Auth.connect("login_failed",self, "_on_login_failed")
provider = Firebase.Auth.get_GoogleProvider()
_on_application_start()
func _on_login_succeeded(user : Dictionary):
$Label.set_text("Successfully logged in with oAuth2 as: {email}".format({email=user.email}))
Firebase.Auth.save_auth(user)
func _on_application_start():
Firebase.Auth.get_auth_localhost(provider, port)
The first time, the user will be asked to choose a Google account and give permissions to the app. Then the user will be redirected to the default page and will be logged automatically in your app. The next times, by calling the same function, the user will be directly redirected to the default page and logged.
If you want to automatically login at startup, you'd want to use save_auth(userinfo)
and load_auth()
(code)
Hope I answered your question. Please let me know if something deosn't work as you were expecting. Eventually if there are any errors, please report them here.
@fenix-hub I think I understand, but in _on_application_start() then just call load_auth() and it will automatically login?
I saw that it calls manual_token_refresh(), but it doesn't emit the "login_succeeded" signal
And on android would it work? what I want to do is something similar to free fire in the login, where you log in once and then you don't have to log in ever again.
@MiqueiasDevGames Yes, it calls manual_token_refresh()
internally but makes it easier for you to manage authentication data, since the plugin will encrypt and save/retrieve it for you.
It should work as there were no issues opened regarding this feature and tests are passing, but of course let us know if something bad happens.
For Android the scenario is a little bit more complex.
The problem is that on Android if you exit the app (like you would normally do in the OAuth2 flow, being redirected to an external page), Godot is not able to listen anymore on requests coming from external platforms. This means that the localhost
method which works very well on desktop is broken, and of course the HTML5 implementation described in our wiki won't work too.
It is a Godot-specific issue more than a plugin limitation, since Godot doesn't support webview, so going to a browser will make Godot stop working in background.
A solution could be to use the desktop method, combined with a Redirect Link to your app (specifically known as App Deep Linking).
The idea is that, when configuring your provider (Google in your case), you set your redirect_uri
to a Deep Link to your app (something like https://my.godotapp.com
or app://my.godotapp.com
).
Then the OAuth2 flow would be the same as the Desktop flow, but instead of redirecting your users to localhost it will redirect you to that URI, which for a Desktop could be your website, but at the same time (same link!) on Android would open your App. Deep Linking calls support parameters (like request uri parameters), so in that case our plugin would be able to get the OAuth2 authorization token from the Deep Linking, and authenticate your user.
The idea should work fine, except:
I hope I've made myself clear. Let me know if you still need help, or perhaps you are insterested in experimenting this topic.
@fenix-hub I'm trying here, using deep links, I'll probably get the link back with the parameters, but then how to pass this to your plugin?
Once you are able to get the link back to your apṗ, we can see together how to manage this, since there is no implementation yet to handle the case, but we can work on it. I'll close this issue since it is unrelated, we can continue this topic both on our Discord or in a Github discussion on this repository (tag me in on it once you opened it).
I can register with email and password, but I cannot login with google. With the get_google_auth_manual method, I can't see any action on either desktop or android.