Giter Site home page Giter Site logo

godotnuts / godotfirebase Goto Github PK

View Code? Open in Web Editor NEW
515.0 15.0 73.0 2.21 MB

Implementations of Firebase for Godot using GDScript

License: MIT License

GDScript 96.85% C++ 0.97% Objective-C++ 1.96% C 0.22%
godot firebase firebase-auth firebase-database firebase-firestore firebase-realtime-database firebase-storage gdscript hacktoberfest hacktoberfest2022

godotfirebase's People

Contributors

aaronfranke avatar adavidm avatar beardooks avatar carmex avatar codecustard avatar fenix-hub avatar leonardmeagher2 avatar lukehollenback avatar pukkah avatar sisilicon avatar theduckcow avatar timjrobinson avatar triptych avatar tzrot-jed avatar vitorgus avatar volzhs avatar wolfgangsenff avatar xzirox avatar zarasan avatar zeedinstein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godotfirebase's Issues

Built-in Documentation

Having a Wiki is great, but as the project grows, perhaps the class documentation should also be included in the editor for faster referencing; similar to how the built-in class references can also be found in the editor.

[BUG] Crash when connecting to Realtime Database

Describe the bug
I'm testing out the updates in #124 and Realtime Database is crashing when trying to listen to a path on this line: https://github.com/GodotNuts/GodotFirebase/blob/main/addons/godot-firebase/database/reference.gd#L123 because _auth_obj is null.

Full stack trace:

2021-02-15 17_56_47-Godot Engine - CodeBreaker - SceneSelector tscn

When I put a breakpoint on https://github.com/GodotNuts/GodotFirebase/blob/main/addons/godot-firebase/database/reference.gd#L26 the onready is called after my code. So it seems I need to wait longer for it to be ready before using it? How can I do that?

To Reproduce

Here's some example code that reproduces it:


func _ready():
	Firebase.Auth.connect("signup_succeeded", self, "_create_game")
	Firebase.Auth.connect("login_succeeded", self, "_create_game")
	Firebase.Auth.connect("login_failed", self, "_on_auth_error")
	Firebase.Auth.login_anonymous()

func _create_game(auth_result : Dictionary):
	var rooms_ref : FirebaseDatabaseReference = Firebase.Database.get_database_reference("/games/code-breaker/rooms/", {})

It crashes in _create_game

Expected behavior

I expect this to connect to that path in the database and not crash.

Environment:

  • OS: Windows 10
  • Running with Godot "Play" button

Firestore doesn't work

I have problem when doing with Firebase Database. I have been figuring out what was going on with it, by analyzing this addon, for why doesn't it work.

The Auth here works, but The Firestore no longer works. I even tried the demo if I made wrong, but infact The demo also no longer works for updloading firebase

I have tried different method to do with Firebase, by trying the simpler script found in GDQuest tutorial here. and its finished file right here. Here I created another script to become the Singleton under different node name, let's say FirebaseQuest.

and GDQuest version works right away (both Auth and Firestore), no problem

here's example of push from GDQuest

func save_document(path: String, fields: Dictionary, http: HTTPRequest) -> void:
	var document := { "fields": fields }
	var body := to_json(document)
	var url := FIRESTORE_URL + path
	http.request(url, _get_request_headers(), false, HTTPClient.METHOD_POST, body)

and yours from FirebaseReference.gd

func push(data):
	var to_push = JSON.print(data)
	if pusher.get_http_client_status() == HTTPClient.STATUS_DISCONNECTED:
		pusher.request(_get_list_url() + db_path + _get_remaining_path(), PoolStringArray(), true, HTTPClient.METHOD_POST, to_push)
	else:
		push_queue.append(data)

Let me now comment what best I could understand. correct me if wrong, it's quite complicated for me to learn back this addon, I know.:

  • GDquest version do concern about request headers in the custom header every HTTP request. Maybe now it is required to have custom header when uploading HTTP, since yours lack the custom header, I think Google rejects it from now on.
  • Note that I had Firestore security rule designed that only allow read and write if user logged in. And again, attempting writing to and reading from there, only GDquest version that works
  • If the HTTP has finished doing its business (HTTPClient.STATUS_DISCONNECTED), well that mean it should be able to write so, since the http is not connected right now.
  • GDQuest version place every data to be pushed or patched with into a dictionary of {"fields":fields} in which the "fields" contains all the data you'd like to push or update with. I think the upload structure might have changed, so it's no longer compatible with older technique.
  • The structure of the data then should looks like
var tobePush = {
		"fields":{
			"Auza":{"stringValue":"aaaaaaaaaaaw"}
		},
	}
  • notice the stringValue there. the datatype has to be defined first. Haven't seen again if your demo had one.
  • So basically, you just do
var data = { "aaaa" : {"stringValue" : "sample" } }
FirebaseQuest.push(data)

and that's it. it works (assuming you abide by your Firestore rule e.g. logged in).

what's going on?

Invalid call. Nonexistent function 'connect_to_host' in base 'Node'.

When I tried to get a database reference, I get the error Invalid call. Nonexistent function 'size' in base 'bool'.
I have placed no filters.
Godot version: 3.2.2, no mono support
Full error:

FirebaseReference.gd:119	if path == separator and data.size() > 0:
FirebaseReference.gd:61		_route_data(command, data.path, data.data)
HTTPSSEClient.gd:86 		emit_signal("new_sse_event", headers, event_data.event, result)

Error code is always 400

When app detect any error it always have code 400 but error message is ok.

but anyway....
THIS PLUGIN IS AWESOME!!!!!!!!!!!!!!!!!!
I finaly found easy to use advanced firebase plugin!

Comments in scripts

I have a request. Add comments to each function with examples for each argument. Otherwise. I do not understand in which argument to enter the file name / path of the file that I want to send / download from the Firebase Storage server. Would you be willing to write an example in the comment on how to send / download a file to / from Firebase Storage? I need this in my online scoreboard in game. And if you can, 'finish' it - #13

Error in "_route_data(command, data.path, data.data)"

in the function on_new_sse_event(headers, event, data): in FirebaseReference.gd "data" comes as an string, then data.path and data.data in _route_data(command, data.path, data.data) fails
i think that can be fixed just likle this: _route_data(command, parse_json(data).path, parse_json(data).data) or in HTTPSSEClient.gd emit_signal("new_sse_event", headers, event_data.event, parse_json(event_data.data)) (that is what i do)

Missing API Key error message with Google Auth enabled

I'm trying this plugin out for an upcoming project. However, I'm having some issues with the login process using an existing Google account.

In my firebase app, I've enabled the google authentication integration, and I have been given both web client ID and secret, but I can't see a way to add this in the plugin.

When I try to login (using Firebase.Auth.login_with_email_and_password) I get a 403 - The request is missing a valid API key.

I've added all the relevant parameters in the Project Settings > Firebase > Environment Variables such as API key, auth domain, etc as provided by Firebase when I've created the app.

I'll take a look in the plugin's code and Firebase API to see if I can integrate something in case is missing, I'd appreciate any help or good pointers.

Thanks

Bugs

I had a few bugs:

  1. When the account was registered, nothing happened and when I clicked the "Login" button
    the "INVAILD_PASSWORD" error popped up, although I did not change anything :(.
  2. How I managed to register (still in the login "INVAILD_PASSWORD" pops up) the "Assertion Failed" pops up in the debugger. After omitting this error, "Invalid get index 'event' appears (on base: 'Nil')."
    All errors apply to the HTTPSSEClient.gd script

OAuth Client ID credentials must be whitelisted in Firebase to work - add note to wiki

No sure if that's just me but when I tried to use the OAuth workflow it didn't work at the beginning and I was getting the following error:

error code: 400
message: INVALID_IDP_RESPONSE : Invalid Idp Response: the Google id_token is not allowed to be used with this application. Its audience (OAuth 2.0 client ID) is xxxxxxxxxxxx.apps.googleusercontent.com, which is not authorized to be used in the project with project_number: yyyyyyyyyyyy

where xxxxxxxxx.apps.etc. it's the client ID I've created in the google console, while yyyyyyy is the project ID in Firebase.

To make it work I've added the google console client ID in the Whitelist for the google sign-in method in Firebase (there is an optional section called "Whitelist client IDs from external projects (optional)".

I thought I should mention this, perhaps it's worth adding this explanation in the Wiki

Invalid call. Nonexistent function 'connect_to_host' in base 'Node'.

I get this error when trying to set a listener to Firebase.Database.get_database_reference().

The error is in line 55 of FirebaseReference.gd:55.

func set_listener(listener_ref):
	if !listener:
		listener = listener_ref
		add_child(listener)
		listener.connect("new_sse_event", self, "on_new_sse_event")
		var base_url = _get_list_url().trim_suffix(separator)
		var extended_url = separator + db_path + _get_remaining_path(false)
		listener.connect_to_host(base_url, extended_url)

The function receives a listener_ref of type Node, which doesn't have the "connect_to_host" method.

Align code style with the official GDScript Style Guide

Align code style with the official GDScript style guide.

This will make the plugin more consistent, giving the main dev team (us) and future contributors a common style more than practices, without changing our way to code but just how it is presented through APIs.

note: heavy refactoring based on files' names and foldering, without changing functionalities or structure.

FirstoreDocument cannot contain collections

While working with Firestore, I managed to create a Document in the console that contains a collection of other documents. This type is currently missing from the list and it would be very useful for our users. I'll work around it for now by adding the same document to the previous collection and find a better way to structure the initial collection name, but we'll need to implement it, since (apparently) this is a valid setup in Firestore.

Source code using double tabs instead of single tabs!

Firstly, thank you for this plugin! It is proving to be very useful in a game I'm working on. I'm even considering to contribute to the storage api.
Something is bothering me about the source code though. all the tabs seemed to have doubled. Where there would be one tab, there's two. Where there'd be two tabs, there's four. This does not adhere to the gdscript style guide in the docs, and also wastes valuable scripting space.

If you'd like, I can do make a pull request with the changes.

Demo project not immediately working

I am trying to run the demo project by cloning (I also correctly updated the HTTPSSEClient submodule in res://addons/GDFirebase/HTTPSSEClient) and scanning the folder. A project named TestFirebaseJS has been located. I initialized everything on Firebase and I am actually logging in and creating an user on Firebase, so it seems to work.

Immediately after the login/user creation I am getting an error "Invalid get index 'Storage' (on base: 'Node (Firebase.gd)')." at https://github.com/WolfgangSenff/GodotFirebase/blob/29839469e2ee0b2b0136b5ca0822cc03530c4b68/Demo/ChatControl.gd#L16 and in fact I do not see any ".Storage" symbol in Firebase.gd (but I am new on Godot/GDScript so this could be my fault). I then noticed that the two Firebase.gd files (https://github.com/WolfgangSenff/GodotFirebase/blob/master/GDFirebase/Firebase.gd vs https://github.com/WolfgangSenff/GodotFirebase/blob/master/Demo/addons/GDFirebase/Firebase.gd) are different, so I tried to overwrite the demo addons/GDIFirebase folder with the other, but still with no luck, same error.

is ChatControl.gd line 16 redundant because the var is already initialized with the correct type at line 5? commenting line 16 seems to work...

Took a while to get everything out (for example the need for submodule update, you should mention it, I tried by just copying the files from a download of the master and it was obviously broken), but all of this seems very interesting. You should do some release or at least tag some known-to-work master commit... Also, would be nice if the demo was aligned with the latest version of the library - again, using a git submodule? But I suppose you should split the repository in two, one with the lib and the other with the demo (never used submodules)...

Thanks, later

Aaron

[FATAL!!! URGENT Security Issue] Firebase Config file is loaded in hard code way...

And that creates big security problem.

  • This plugin reads the config in Firebase.gd, which means hard coded, instead of doing so from separate .gitignore-able file
  • Developer will forgot to .gitignore this,
  • which can cause the private keys (like Google API keys) in that config spread wild and could be abused if they decided to make their game anything source available (Open Source, and so), and uploaded it to public like GitHub, GitLab, or any version control Git thingy.
  • This could jeopardize entire Firebase project! anyone could hack and mess around with that.

How to fix this? LOAD FROM SEPARATE FILE!

  • Create better setup way using a window that let user insert the config data into each LineEdit.
  • After clicking save, the window will save it on a separate setup save file.
  • .gitignore will also be created ignoring the setup save file.

Workaround

let's say you are Open Source and upload to GitHub. I use GitHub Desktop to do Git easily with UI.

  • just .gitignore Firebase.gd once you are going to use it.
  • or if you don't want to immediately ignore Firebase.gd (because other cloners could get script not found error during project load), maybe don't fill the config just yet before the fix comes.

Add FirebaseTileMap component

As we start to build out Firebase-UI-like components, I thought it made sense to have a TileMap that could maintain itself via an active connection to Firebase. This should also give an easy way to upload the map data to Firestore so that people can build their maps in the editor and effectively "export" them to Firestore.

HTTPSSEClient Assertion failed.

Hey, I am getting on "Assertion failed." error after trying to "get_database_reference".

image

UPD: It was purely a Firebase related issue.

Other functions

As far as possible, add other functions such as logging in and registering in with all FireBase-supported methods and restoring the user account password

Add ability to logout

Is your feature request related to a problem? Please describe.
Currently there is no way to have a user log out of the system or remove the local auth file

Describe the solution you'd like
A method to do this

Describe alternatives you've considered
N/A

Additional context
N/A

Fix plugin paths due to recent breakage, refactor for tscn solution rather than dynamic nodes

Recently, an update broke the paths to the http-see-client plugin in the demo as well as the main solution. It shouldn't affect how the Firebase plugin itself works, nor the demo, but it bothers me, so I'm fixing it.

Along with that, I'm refactoring the code so the singleton used is a scene rather than a script; this gets us the ability to have nodes under the parent that represent the features implemented.

Can't get document with .get()

Hi, I can't get document from collection, which already exists (I created document on Firebase side)
Collection name is 'allusers' and document name is 'admin'

func _on_Button2_pressed():
	# get existing document
	var coll = Firebase.Firestore.collection('allusers')
	var doc = coll.get('admin')
	print(doc) # prints Null

I noticed that in firestore.gd, collections variable is also Null:

func collection(path : String) -> FirestoreCollection:
		if !collections.has(path):
				var coll : FirestoreCollection = FirestoreCollection.new()
				coll.extended_url = extended_url
				coll.base_url = base_url
				coll.config = config
				coll.auth = auth
				coll.collection_name = path
				print(collections)                            # prints Null
				collections[path] = coll
				add_child(coll)
				return coll
		else:
				return collections[path]

which is incorrect as collection and all data exists.

Confused the Databasing type between Realtime Database & Cloud Firestore

Recontinue issue #33 ...

Oh. no..

It works if you setup Realtime Database

I've misunderstood this concept of this addon the whole time. I bet people had misunderstood this too. I think you should add instruction how to start the database which is Realtime Database, since Firebase has 2 types of Databasing (Cloud Firestore & Realtime Database.

Let me clarify:

  • This addon as you can see with the demo uses Realtime Database. Not to be confused with Cloud Firestore.
  • Realtime Database uses References I mentioned earlier.
  • So if you did not see the change coming right up in the databaser, it's not Cloud Firestore! it's Realtime Database!

What did I do?

  • I've compared between this addon and GDquest
  • Yes, GDquest did not handle streamed updated. This one, updates something like Authentication key after certain times, as I saw in FirebaseAuth thingy, method begin_refresh
  • I've read mentioned script you told. it seems that this demo nor the plugin itself no longer used some part of the script like one you mentioned anymore. tell me if I'm wrong. I've tried my best to figured which script loads which and did the script being loaded from that script; basically complexity.
  • I've read from issue #28 that the demo used to use something like Firebase Storage, wait. this is File hosting. nvm. idk.
  • Wait, Firebase Storage script isn't referenced in the initialization _ready() on main Firebase.gd anymore? Haven't seen the node reference of Storage....
  • I can only see Firebase.Auth, and Firebase.Database . that's it. where's the other? is it separately referenced out of Firebase.gd? it seems those unreferenced ones supposed to be referenced via Firebase.gd first beforehand, but it's absent Firebase.Firestore, Firebase.Storage, or whatever other. Because it had no self initialization _ready like to connect signals to parent node whom the node was instancing.
  • Manually curl this back and forth, to make sure from other types of client.

Curl I did in cmd.exe

https://firebase.google.com/docs/reference/rest/database?hl=en . I didn't know that I do is for Realtime Database

curl -X POST -d "{ \"first\": \"Jack\", \"last\": \"Sparrow\" }" "https://sandboxon-407f9.firebaseio.com/users/jack/name.json"

Above is when Project-id.firebaseio.com which is Realtime Databse

https://www.youtube.com/watch?v=-vDNk7BzOGc
https://github.com/GDQuest/godot-demos/blob/master/2019/05-21-firebase-firestore/end/interface/profile/UserProfile.gd . I tried to manually makeshift the curl synthax to replicate the HTTPCLient's request. It did work if did in supposed way, but I couldn't figure out working synthax for cmd.exe.

curl -X POST -d {"fields":{"Crondle":{"stringValue":"JOELwindows7"}}} "https://firestore.googleapis.com/v1/projects/sandboxon-407f9/databases/(default)/documents/PlesWork/unadio10"

โš  Command not work. Above is when firestore.googleapis.com which is cloud firestore.

So what's the problem?

I confused the Databasing feature as Cloud Firestore as most Tutorials that covers it, implements Firebase database feature, prepares Cloud Firestore, while actually this Plugin did used Realtime Database instead, as in the demo and what Firebase.gd currently initialize.

Bellow this is when it finally works
It works if you setup Realtime Database

What I supposed to do is to Setup Realtime Database from now.
Oh, Realtime Database?

Instead of Cloud Firestore (Though you should prepare that too just in case needed later).
I thought it uses this

Because the demo uses Realtime Database. oh, I didn't know that.

Edit: Solutions

  • Add steps to setup Realtime Database, so customer won't be confused which Databasing should be prepared
  • Readd Cloud Firestore reference in Firebase.gd . It seems that it is absent or idk..
  • more features idk

Refresh Token Missing

I get missing refresh token after the login has timed out, how do I set it up so it refreshes while the application is opened?

Firebase storage

Hi,

I just want to know if it's works for firebase storage ans if the plugin works on android

thanks

Issues with Installation documentation

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

  • It mentions copying GDFirebase to addons folder. But this repo has 3 folders in master: godot-firebase, gut, and http-sse-client. Do all 3 of these need to be copied?
  • In the override.cfg file I filled in the variables but they didn't appear in Project Settings after reload. it has [firebase/environment_variables] at the top. I changed this to [GodotFirebase/environment_variables] (so it's the same as the plugin name) and then the environment variables turned up in the editor.

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.

Integration Question

Does this work for iOS? Also do the analytics work? Looking for something that would track conversion events for installs from Google Ads.

New OAuth integration with google credentials - passwordUpdatedAt is not in the payload therefore raising exception error

I'm testing the new OAuth integration (btw thanks a million to implementing this feature so quickly!!), I've got an error in the FirebaseUserData class (file: user_data.gd), the exception is raised for row 20 where the field passwordUpdatedAt is not in the payload returned by google during the authentication transaction.

I've commented the row for now and it all worked fine after few other hiccups that got sorted automagically (if it happens again I'll open a new issue)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.