thisbejim / Pyrebase

A simple python wrapper for the Firebase API.
2.05k stars 525 forks source link

If config is placed in .env file #438

Open gavinchris37 opened 1 year ago

gavinchris37 commented 1 year ago

from views import ChangeRoute File "D:\aaapro\limefin\views.py", line 48, in firebase = pyrebase.initialize_app(CONFIG) File "D:\aaapro\limefin\lfenv\lib\site-packages\pyrebase\pyrebase.py", line 28, in initialize_app return Firebase(config) File "D:\aaapro\limefin\lfenv\lib\site-packages\pyrebase\pyrebase.py", line 34, in init self.api_key = config["apiKey"] TypeError: string indices must be integers

AsifArmanRahman commented 1 year ago

@gavinchris37 you're reading the environment variable as string, thus you're receiving the below error.

TypeError: string indices must be integers


The following snippet should fix it:


import json

firebase = pyrebase.initialize_app(json.loads(CONFIG))



If it helps, please check firebase-rest-api which is uses updated libraries and some new features.