GodotNuts / GodotFirebase

Implementations of Firebase for Godot using GDScript
MIT License
554 stars 79 forks source link

Issues with Installation documentation #79

Closed timjrobinson closed 3 years ago

timjrobinson commented 3 years ago

Just installing following https://github.com/GodotNuts/GodotFirebase/wiki/Installation-and-Activation and found a few issues:

When I try to use Firebase it's giving me No configuration settings found, add them in override.cfg file. I assume this is because it's not detecting the environment variables correctly maybe because of the name change. Looking into this now.

timjrobinson commented 3 years ago

After a few restarts the env variables started showing in project settings with [firebase/environment_variables] at the top of the config file, so I guess that 2nd part is fine. I'm still getting "unauthorized" though.

timjrobinson commented 3 years ago

Hmm I can't figure out what's going on. I don't have clientId or clientSecret set but the rest of the settings are set. I'm printing out the config in auth.set_config - https://github.com/GodotNuts/GodotFirebase/blob/main/addons/godot-firebase/auth/auth.gd#L116 and they're all set correctly. However after this function nothing further happens, the _on_FirebaseAuth_request_completed function is never hit.

I tried this same config in a simple web project and it worked and posted to the firestore correctly, so they are valid.

timjrobinson commented 3 years ago

Ok got it working! Didn't realize I must login with a user to be able to use the Firestore, as this isn't required in Firebase web apps. I first enabled Authentication -> Sign-in method -> Anonymous and then the following works:

Firebase.Auth.connect("login_succeeded", self, "_get_test_item")
Firebase.Auth.login_anonymous()

func _get_test_item((auth_result : Dictionary):
    var COLLECTION_ID = 'test-collection'
    var DOCUMENT_ID = 'test-doc'

    var collection : FirestoreCollection = Firebase.Firestore.collection(COLLECTION_ID)
    collection.get(DOCUMENT_ID)
    var document : FirestoreDocument = yield(collection, "get_document")
    print("Document is: ", document)

Trying to run that _get_test_item function without doing Auth.login_anonymous() doesn't work. It just says unauthorized

fenix-hub commented 3 years ago

Hi @timjrobinson , I'm sorry about the installation experience - the wiki still needs some updates since we are still figuring a proper basic way to install and set up the plugin. We will update that page as soon as possible with the current method.

About authentication - since we are using REST APIs, due to security reasons (both from Firebase and - always remember - your Firestore/Database rules) an authentication is always needed in order to issue requests to the backand. The unauthorized error is pretty self-explainatory from this perspective: before issuing requests to Firestore/Database, a client needs to be authorized. Then you are completely free to authorized via an anonymous user, rather than register a new one, signing up with an already registered user with mail/password combination, or use Google OAuth 2 authentication method.

For the last one, you will need to setup those two keys you currently don't have displayed in Firebase, which are clientId and clienteSecret.

Follow this page if you are interested in Google OAauth 2. It is not mandatory to use as an auth method, and we are still testing it.

Please, if you think my answer was exhaustive, close this issue. Feel free to open new issues or just ask here if you need.

Regards,

fenix-hub commented 3 years ago

wiki updated

WolfgangSenff commented 3 years ago

I'm going ahead and closing this, @timjrobinson. If you have any further issues around it, please open a new one. Thanks!