简体   繁体   English

'默认的 Firebase 应用不存在。 确保通过调用 initialize_app()' 初始化 SDK

[英]'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.我正在尝试使用用于数据存储的 Firebase 实时数据库制作一个 python discord 机器人。 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()我在脚本开头初始化应用程序,但是,当我尝试创建引用时,出现错误The default Firebase app does not exist. Make sure to initialize the SDK by calling initialize_app() The default Firebase app does not exist. Make sure to initialize the SDK by calling initialize_app() . 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!非常感谢您的帮助!

Turns out, if you give the application no name it will start working again.事实证明,如果您不给应用程序命名,它将再次开始工作。 Thanks to MatsLindh for the answer.感谢 MatsLindh 的回答。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 默认的 Firebase 应用不存在。 确保在使用任何 Firebase 服务之前调用 initializeApp()。 在 FirebaseAppError - The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services. at FirebaseAppError 错误默认的 Firebase 应用已经存在。 这意味着您多次调用 initialize_app() 而没有提供应用程序名称作为 - ERROR The default Firebase app already exists. This means you called initialize_app() more than once without providing an app name as the android 清单中所需的元数据标记不存在。 应用程序在 MobileAds.initialize() 崩溃; - A required meta data tag in your android manifest does not exist. App crash at MobileAds.initialize(); ReactNative 在应用程序启动时初始化 Firebase? - ReactNative initialize Firebase at app start? Firebase SDK for Python:如何使用apiKey初始化App? - Firebase SDK for Python: How to initialize App using apiKey? 我无法使用正确的详细信息验证 Firebase。 获取错误:确保使用服务帐户凭据初始化 SDK - I can't authenticate Firebase with correct details. Get error: Make sure to initialize the SDK with a service account credential 我的 expo 应用程序一直显示 Firebase: No Firebase App [DEFAULT] 即使在我初始化它之后 - My expo app keeps displaying Firebase: No Firebase App [DEFAULT] even after i initialize it 如何在 firebase 管理员中初始化多个应用程序 - how to initialize multiple app in firebase admin Flutter firebase 未初始化 - Flutter firebase does not initialize 你应该在哪里初始化你的 firebase web 应用程序? - Where are you supposed to initialize your firebase web app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM