''The default Firebase app does not exist. Make sure to initialize the SDK by calling initialize_app()'
I'm trying to make a python discord bot with the use of the Firebase Realtime Database for datastores. I'm initializing the app at the start of the script, however, when I try to create a reference I get the error The default Firebase app does not exist. Make sure to initialize the SDK by calling initialize_app(). I don't know why this is happening since I initialized it?
Some code samples:
### I initialise the firebase app here?
# Variable def
client = commands.Bot(command_prefix=">", help_command=None)
slash = SlashCommand(client, sync_commands=True)
token = os.environ['TOKEN']
BotGuilds = [916737523017986079]
cred_obj = firebase_admin.credentials.Certificate('rtdb-key.json')
firebase_admin.initialize_app(cred_obj, {
'databaseURL':'https://datastoretuu-default-rtdb.firebaseio.com/'
}, f"main_bot")
### Cause of error
async def info(ctx: SlashContext, player: str=None):
if player is None:
player = ctx.author.nick
tuu_logo = get(ctx.guild.emojis, name="tuu")
pm_logo = get(ctx.guild.emojis, name="pm")
roblox_logo = get(ctx.guild.emojis, name="roblox")
discord_logo = get(ctx.guild.emojis, name="discord")
apiresponse = requests.get(f"https://api.roblox.com/users/get-by-username?username={player}").json()
playerid = apiresponse['Id']
current_ref = db.reference(f"TUUPointStorage/{playerid}/Points")
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Error is here
result = current_ref.get()
Help is greatly appreciated!
Solution 1:[1]
Turns out, if you give the application no name it will start working again. Thanks to MatsLindh for the answer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | alfiewander |
