Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Pyrebase4 Example

Setup

Assuming you have created and initialized a Firebase project:

  • Specify the project ID and Key in main.py.
  • Specify the Realtime Database Rules.
  • Install the dependencies.

Specify the project ID and Key

Get the "apiKey" and "Project ID" for your project from Firebase->Project Overview->Project settings->General and replace these placeholders in main.py:

APIKEY = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
PROJECT_ID = 'bbbbbbbbbb'

Specify the Realtime Database Rules:

In "Firebase->Build->Realtime Database->Rules" replace the default rules with these rules, then publish.

{
  "rules": {
    "id": {	
      "$uid" : {
          ".read": "$uid === auth.uid",
    	  ".write": "$uid === auth.uid"
      }		
    },	
    "data": {	
      "$uid" : {
        ".read": "$uid === auth.uid",
    	".write": "$uid === auth.uid"
      }		
    },
    "more_data": {	
      "$uid" : {
    	".read": "$uid === auth.uid",
    	".write": "$uid === auth.uid"
      }		
    }	    
  }
}

This example uses the "Production-ready rules", for "content-owner only access". Google Docs.

To see the database contents, go to "Firebase->Build->Realtime Database->Data"

Install the dependencies

Desktop

pip3 install pyrebase4

Buildozer

requirements = python3,kivy, pyrebase4, gcloud, googleapis-common-protos, protobuf, httplib2, pyparsing, oauth2client, pyasn1, pyasn1-modules, rsa, pycryptodome, python-jwt, jws, requests, certifi, charset-normalizer==2.1.1, idna, urllib3, requests-toolbelt , jwcrypto, cryptography, deprecated, wrapt

android.permissions = INTERNET

kivy-ios

As of 2022/08 Pyrebase4 does not run on kivy-ios. The error message is OSError: Cannot load native module 'Crypto.Hash._SHA256'..... and it is due to the lack of a pycryptodome recipe.