GodotNuts / GodotFirebase

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

Oauth automatic redirect #205

Closed fenix-hub closed 3 years ago

fenix-hub commented 3 years ago

Related to #203 This PR implements the possibility to automatically login/signup using OAuth2 Authentication method

Two new functions are implemented 1) get_google_auth_redirect(redirect_uri : String, listen_to_port : int) to set a custom redirect_uri where Google will send the token required to be exchanged for a Firebase one 2) get_google_auth_localhost(port : int) to set the loopback ip as the redirect_uri to get the token back automatically

Both functions listen to the port 49152 by default.

While the first function needs to be tested using different URI other than the loopback one, the second function has been tested.

Once get_google_auth_localhost() is called, the browser will automatically open to asking the user to use a Google account o authenticate. Then the user will be redirected to the redirect_uri chosen (which is localhost:49152 for this function) and Godot will automatically get the token. Once the token is retrieved, the plugin will automatically exchange the token a make a sign up request.

NOTE: get_google_auth() is now renamed to get_google_auth_manual()