Skip to content

Installation and Activation

Nicolò Santilio edited this page Jan 20, 2021 · 38 revisions

Installation

  1. Copy the folder GDFirebase to the project path res://addons/
  2. Open your Project Settings
  3. Go to Plugins
  4. Activate the GDFirebase plugin
    Plugin Section
  5. From there, you will have an autoload singleton with the variables Auth and Database. Reference it by using Firebase.Auth, etc.

Activation

  1. Go create a Firebase app at console.firebase.google.com. A Guide can be found Here

  2. Once the app has been created, add a web app to it:

    1. Click on the Project Settings option
      FB Project Settings

    2. Click on the Add App button
      FB Add App

    3. Click the Web App button
      FB Web App

    4. Add a name to your web app and click Register App
      FB Register App

  3. This will show a series of values called "config". To use them you have two options:

    1. Take those values and copy them to the appropriate variables in res://addons/godot-firebase/Firebase.gd.

    2. (Recommended) Create a override.cfg file at the root of the project (specifically, res://override.cfg). Specify those values as environment variables in this file (see example structure below). Reload the project, and you will find a new category inside Project ↝ Project Settings ↝ General ↝ Firebase, which is Environment Variables. Fill all the fields inside this new category and you will be good to go.

[firebase/environment_variables]

apiKey=""
authDomain=""
databaseURL=""
projectId=""
storageBucket=""
messagingSenderId=""
appId=""
measurementId=""

Project Settings Firebase

  1. Use Firebase.Database.get_database_reference(path, filter) to add a listener at a given path in your database. It will return to you a value to which you can hook up to a few different signals, and to which you can push data. You do not have to manually add it to the scene tree, as it gets added automatically. You can listen to many places at once, as needed. You can, optionally, pass a Dictionary of tags (found in FirebaseDatabase) to values representing your filters and queries. Queries are currently cached, so they can't be dynamically updated, but I can add that if there's a desire.

(Additional) OAuth configuration

In order to let users login with their own Google account to your app, the OAuth authentication process must be configured to work with this Plugin.
This process will not be enabled with the main configuration, but still it is not mandatory to use standard login methods.
To enable Google OAuth Authentication, follow these steps:

  1. In your project, enable "Google" in "Sign-in Method": enable_sign_in
  2. Go to console.cloud.google.com/apis/credentials: go_to
  3. Select the project you are working on (and eventually, your organization): select_project
  4. Press the "+ Create Credentials" button and chose "ID Client OAuth" to register new credentials: create_credentials
  5. Select Desktop Application, then give a name to your credentials: desktop
  6. Create your credentials and copy-paste them in the configuration file override.cfg, or directly in your code: keys config
Clone this wiki locally