این صفحه مجموعهای از سوالات متداول و کمک به عیبیابی Firebase به طور کلی و همچنین برای محصولات خاص است.
آیا چالشهای دیگری دارید یا نمیتوانید مشکل خود را که در این صفحه توضیح داده شده است، پیدا کنید؟
برای نکات مفید و پاسخهای مربوط به سوالات متداول بیشتر، از صفحات عیبیابی و سوالات متداول مخصوص پلتفرم دیدن کنید.
در اینجا مهمترین نکاتی که باید در مورد کلیدهای API برای سرویسهای Firebase بدانید، آورده شده است:
- عمومی از نظر طراحی : کلیدهای API برای سرویسهای Firebase فقط پروژه و برنامه Firebase شما را به آن سرویسها معرفی میکنند . مجوز از طریق مجوزهای IAM Google Cloud ، Firebase Security Rules و Firebase App Check انجام میشود.
- Security Rules و App Check بسیار مهم هستند : امنیت دادههای Realtime Database ، Cloud Firestore و Cloud Storage شما با استفاده از Firebase Security Rules اعمال میشود و حفاظت از APIهای تحت پوشش توسط Firebase App Check انجام میشود - نه با مخفی نگه داشتن کلید API Firebase شما.
- اعمال محدودیتها : اگرچه این موضوع مخفی نیست، اما همچنان باید محدودیتهایی را در کنسول Google Cloud اعمال کنید تا از استفاده غیرمجاز از سهمیه پروژه خود برای سایر APIها جلوگیری کنید. تمام کلیدهای API ارائه شده توسط Firebase به طور خودکار به APIهای مرتبط با Firebase محدود میشوند.
- فقط برای سرویسهای Firebase استفاده شود : از کلیدهای API ارائه شده توسط Firebase خود فقط برای APIهای مرتبط با Firebase استفاده کنید. اگر برنامه شما از APIهای دیگری استفاده میکند (مثلاً API Places برای نقشهها یا API توسعهدهنده Gemini )، از یک کلید API جداگانه استفاده کنید و آن را به API مربوطه محدود کنید.
اگر تنظیمات برنامه شما از دستورالعملهای بالا پیروی میکند، نیازی نیست کلیدهای API محدود به سرویسهای Firebase به عنوان اطلاعات محرمانه در نظر گرفته شوند و میتوان آنها را با خیال راحت در کد یا فایلهای پیکربندی خود قرار داد.
اگر ایمیلی از Google Cloud در مورد «کلید API گوگل قابل دسترس برای پروژه Google Cloud شما» دریافت کردهاید و کلید API ذکر شده در ایمیل، کلید API فایربیس شماست ، مطمئن شوید که کلید API الزامات زیر را برآورده میکند تا بتوانید آن را با خیال راحت در کد یا فایلهای پیکربندی خود قرار دهید. میتوانید موارد زیر را در پنل APIها و خدمات > اعتبارنامهها در کنسول Google Cloud تأیید کنید.
- این کلید API است که شما برای برنامه Firebase خود و فقط برای سرویسهای Firebase استفاده میکنید. این کلیدها معمولاً
Browser key (auto created by Firebase)یاAndroid key (auto created by Firebase)یاiOS key (auto created by Firebase)نامیده میشوند. - این کلید، تمام APIهای مورد نیاز مربوط به Firebase را که در لیست مجاز «محدودیتهای API» قرار دارند، داراست .
- هیچ API دیگری در فهرست مجاز «محدودیتهای API» خود ندارد . به طور خاص، این فهرست نباید شامل
Generative Language APIباشد.
همچنین، مطمئن شوید که Firebase Security Rules و App Check ، همانطور که برای محصولات Firebase مورد استفاده شما توصیه شده است، استفاده میکنید.
میتوانید جزئیات مربوط به کلیدهای API برای Firebase را بیاموزید و فهرستی از سوالات متداول را در «درباره استفاده و مدیریت کلیدهای API برای Firebase بیاموزید» بیابید.
کنسول Firebase یک تجربه برنامه نمونه ارائه میدهد تا شما یک برنامه کاربردی واقعی برای کاوش و آزمایش با فایربیس و سایر سرویسهای گوگل (مانند Gemini API ) داشته باشید.
وقتی تجربه برنامه نمونه را در کنسول Firebase مرور میکنید، ما به طور خودکار موارد زیر را برای شما انجام میدهیم:
- یک پروژه Firebase جدید برای برنامه نمونه خود ایجاد کنید
- یک برنامه وب Firebase را در پروژه جدید Firebase ثبت کنید
- سرویسها و APIهایی را که توسط برنامه نمونه استفاده میشوند فعال کنید (برای مثال، Firebase Authentication ، Cloud Firestore و غیره)
- منابع مورد نیاز را فراهم کنید (برای مثال، نمونههای پایگاه داده و قوانین امنیتی)
- تنظیم Firebase AI Logic برای استفاده از Gemini Developer API
- برنامه نمونه را با استفاده از Firebase Hosting روی یک URL پیشنمایش موقت مستقر کنید (به طور پیشفرض، این URL ظرف ۷ روز منقضی میشود )
گزینه ۱: یک نسخه شخصیسازیشده از کدبیس برنامه نمونه را در Firebase Studio باز کنید
تجربه برنامه نمونه، مسیری را برای باز کردن یک نسخه شخصیسازیشده از کدبیس برنامه نمونه در Firebase Studio (فضای کاری مبتنی بر مرورگر گوگل برای توسعه برنامه کامل) فراهم میکند. پس از راهاندازی پروژه و برنامه شما (به بالا مراجعه کنید)، میتوانید پیوندهایی به Firebase Studio را در بنرهای کنسول Firebase و در بالای برنامه مستقر شده پیدا کنید.
وقتی برنامه نمونه خود را در Firebase Studio باز میکنید، ما به طور خودکار موارد زیر را برای شما انجام میدهیم:
- از همان پروژه Firebase، برنامه وب Firebase و منابعی که در تنظیمات اولیه ایجاد شدهاند استفاده کنید (به بالا مراجعه کنید)
- پیکربندی Firebase برنامه نمونه خود را در کدبیس (معمولاً در
src/bootstrap.js) وارد کنید.
در Firebase Studio ، میتوانید کدبیس را بررسی کنید تا نحوه تعامل با سرویسهای مختلف Firebase و Google را درک کنید.
گزینه ۲: مشاهده نسخه عمومی و غیرشخصیشده کدبیس برنامه نمونه در گیتهاب
از طرف دیگر، میتوانید نسخه عمومی و غیرشخصیشدهی کدبیس برنامهی نمونه را در گیتهاب مشاهده کنید.
- «برنامهریزی با رابط برنامهنویسی Gemini» - مخزن گیتهاب
برای سوالات متداول در مورد قیمتگذاری مربوط به یک محصول، به بخش مربوط به آن محصول در این صفحه یا در مستندات اختصاصی آن محصول مراجعه کنید.
سرویسهای پولی فایربیس را میتوان تحت دوره آزمایشی رایگان Google Cloud استفاده کرد. کاربران جدید Google Cloud و فایربیس میتوانند از یک دوره آزمایشی ۹۰ روزه که شامل ۳۰۰ دلار اعتبار رایگان Cloud Billing است، برای بررسی و ارزیابی محصولات و خدمات Google Cloud و فایربیس استفاده کنند.
در طول دوره آزمایشی رایگان Google Cloud ، یک حساب Cloud Billing به شما ارائه خواهد شد. هر پروژه فایربیس که به آن حساب کاربری متصل باشد، در طول دوره آزمایشی رایگان، در طرح قیمتگذاری پرداخت در حین استفاده Blaze قرار خواهد گرفت.
Don't worry, linking a Firebase project to this Free Trial Cloud Billing account does not enable us to charge you for usage beyond these credits . You are not charged for usage beyond these credits unless you explicitly enable billing by upgrading your Free Trial Cloud Billing account to a paid account. You can upgrade to a paid account at any time during the trial. After you've upgraded to a paid account, you can still use any remaining credits (within the 90-day period).
Once the free trial expires and if you have not upgraded the Free Trial Cloud Billing account to a paid account, then your linked Firebase project is automatically downgraded to the Spark pricing plan . Note that you can upgrade to the Blaze pricing plan again at any time.
Learn more about the Google Cloud Free Trial .
Visit the A/B Testing troubleshooting & FAQ page for helpful tips and answers to more FAQs.
To help protect your project from SMS traffic pumping and API abuse, take the following steps:
View your regional SMS usage .
Look for regions with a very high number of sent SMS and a very low number (or zero) of verified SMS. The ratio of verified/sent is your success rate. Healthy success rates are commonly in the 70-85% range since SMS is not a guaranteed delivery protocol, and some regions may experience abuse. Success rates lower than 50% imply many sent SMS but few successful logins, which is a common indicator of bad actors and SMS traffic pumping.
Use SMS Region Policy to either deny SMS regions with low success rates, or only allow certain regions if your app is only intended for distribution in certain markets.
Use the Authentication settings dashboard to manage authorized domains. The localhost domain is added by default to the approved authentication domains to simplify development. Consider removing localhost from the authorized domains in your production project to prevent bad actors from running code on their localhost to access your production project.
Enable App Check to help protect your project from API abuse by attesting that requests only come from applications associated with your project.
To use App Check with Firebase Authentication , you must upgrade to Firebase Authentication with Identity Platform .
Remember that you need to enforce App Check for Authentication in the Firebase console (consider monitoring traffic before enforcing). Also, double check your reCAPTCHA Enterprise approved sites list to validate that it only contains your production sites, and that the list of applications registered to your project in App Check is accurate.
Note that App Check helps protect against automated attacks by asserting that the call comes from one of your registered applications. It does not prevent users from using your app in unintended ways (for example, starting then never finishing login flows to generate sent SMS).
At this time, numbers ported between carriers will result in all SMS becoming undeliverable for those end users. There is no workaround, and Firebase is working on this issue.
Follow the troubleshooting steps in this FAQ if you're getting the following error:
GoogleFragment: Google sign in failed
com.google.android.gms.common.api.ApiException: 13: Unable to get token.
at
com.google.android.gms.internal.auth-api.zbay.getSignInCredentialFromIntent(com.google.android.gms:play-services-auth@@20.3.0:6)
Make sure that Google sign-in is properly enabled as an authentication provider:
In the Firebase console, open the Authentication section .
Within the Sign in method tab, disable and then re-enable the Google sign-in method (even if it's already enabled):
Open the Google sign-in method, disable it, and then click Save .
Re-open the Google sign-in method, enable it, and then click Save .
Make sure that your app is using its up-to-date Firebase configuration file (
google-services.json).
Obtain your app's config file.Check if you're still getting the error. If you are, continue to the next troubleshooting step.
Make sure the required underlying OAuth 2.0 clients are present.
In the Credentials page of the Google Cloud console, look in the OAuth 2.0 Client IDs section.
If OAuth 2.0 clients are not present (and you've done all the troubleshooting steps above), then contact Support .
Follow the troubleshooting steps in this FAQ if you're getting the following error:
You must specify |clientID| in |GIDConfiguration|
Make sure that Google sign-in is properly enabled as an authentication provider:
In the Firebase console, open the Authentication section .
Within the Sign in method tab, disable and then re-enable the Google sign-in method (even if it's already enabled):
Open the Google sign-in method, disable it, and then click Save .
Re-open the Google sign-in method, enable it, and then click Save .
Make sure that your app is using its up-to-date Firebase configuration file (
GoogleService-Info.plist).
Obtain your app's config file.Check if you're still getting the error. If you are, continue to the next troubleshooting step.
Make sure the required underlying OAuth 2.0 clients are present.
In the Credentials page of the Google Cloud console, look in the OAuth 2.0 Client IDs section.
If OAuth 2.0 clients are not present (and you've done all the troubleshooting steps above), then contact Support .
Follow the troubleshooting steps in this FAQ if you're getting the following error:
AuthErrorCode.INVALID_OAUTH_CLIENT_ID
Make sure that Google sign-in is properly enabled as an authentication provider:
In the Firebase console, open the Authentication section .
Within the Sign in method tab, disable and then re-enable the Google sign-in method (even if it's already enabled):
Open the Google sign-in method, disable it, and then click Save .
Re-open the Google sign-in method, enable it, and then click Save .
Also, in the Google sign-in provider configuration of the Authentication section, make sure that the OAuth client ID and secret match the web client displayed in the Credentials page of the Google Cloud console (look in the OAuth 2.0 Client IDs section).
Follow the troubleshooting steps in this FAQ if you're getting the following error:
This domain YOUR_REDIRECT_DOMAIN is not authorized to run this operation.
This error is most likely caused because your redirect domain isn't listed as a authorized domain for Firebase Authentication , or the API key that you use with the Firebase Authentication Service is invalid.
First make sure that YOUR_REDIRECT_DOMAIN is in the list of authorized domains for your Firebase project. If your redirect domain is already listed there, continue to troubleshoot an invalid API key.
By default, Firebase Authentication JS SDK relies on the API key for your Firebase project that's labeled as the Browser key , and it uses this key to verify that a sign-in redirect URL is valid according to the list of authorized domains. Authentication gets this API key depending on how you access the Authentication SDK:
If you use Hosting -provided Auth helpers to log users in with the Authentication JS SDK, then Firebase automatically obtains your API key with the rest of your Firebase configuration each time you deploy to Firebase Hosting . Make sure that the
authDomainin your web appfirebaseConfigis properly configured to use one of the domains for that Hosting site. You can verify this by going tohttps:// authDomain __/firebase/init.json, and checking that theprojectIdmatches that from yourfirebaseConfig.If you self-host the sign-in code , then you can use a
__/firebase/init.jsonfile to provide the Firebase configuration to the self-hosted Authentication JS SDK Redirect helper. The API key and theprojectIdlisted in this config file should match your web appfirebaseConfig.
Check to make sure this API key hasn't been deleted: Go to the APIs & Services > Credentials panel in the Google Cloud console where all the API keys for your project are listed.
If the
Browser keyhas not been deleted, check the following:Make sure the Firebase Authentication API is in the list of allowed APIs for the key to access ( learn more about API restrictions for API keys ).
If you self-host the sign-in code, make sure the API key listed in your
__/firebase/init.jsonfile matches the API key in the Google Cloud console. Correct the key in the file, if necessary, then redeploy your app.If the
Browser keyhas been deleted, you can have Firebase generate a new API key for you: In the Firebase console, go to> Project settings , then in the Your apps section, click your web app. This action automatically creates an API key that you can see in the SDK setup and configuration section for your web app.
Note that in the Google Cloud console this new API key won't be called
Browser key; instead, it will be the same name as your Firebase Web App's nickname. If you decide to add API restrictions to this new API key, make sure the Firebase Authentication API is in the list of allowed APIs.Once your new API key is created, complete the applicable steps below:
If you use reserved Hosting URLs , then redeploy your app to Firebase so that it can automatically obtain the new API key with the rest of your Firebase configuration.
If you self-host the sign-in code , copy the new API key and add it to your
__/firebase/init.jsonfile, then redeploy your app.
Open the Credentials page of the Google Cloud console.
At the top of the page, select Create credentials > OAuth client ID .
If you're prompted to configure your consent screen, follow the on-screen instructions, and then continue with the following steps of this FAQ.
Create the OAuth web client:
For the Application Type , select Web application .
For the Authorized JavaScript Origins , add the following:
-
http://localhost -
http://localhost:5000 -
https:// PROJECT_ID .firebaseapp.com -
https:// PROJECT_ID .web.app
-
For the Authorized Redirect URIs , add the following:
-
https:// PROJECT_ID .firebaseapp.com/__/auth/handler -
https:// PROJECT_ID .web.app/__/auth/handler
-
Save the OAuth client.
Copy the new OAuth client ID and client secret to your clipboard.
In the Firebase console, open the Authentication section .
Within the Sign in method tab, open the Google sign-in provider, and then paste the web server client ID and secret you just constructed and copied from the Google Cloud console. Click Save .
Before December 2022, the %APP_NAME% in the email template was populated with the OAuth brand name that was automatically provisioned whenever an Android app was registered in the Firebase project. Now, since the OAuth brand is provisioned only when Google sign-in is enabled, the following describes how %APP_NAME% is determined:
If the OAuth brand name is available, then the
%APP_NAME%in the email template will be the OAuth brand name (same as pre-December 2022 behavior).If the OAuth brand name is not available, here's how the
%APP_NAME%in the email template is determined:For web apps , the
%APP_NAME%will be the default Firebase Hosting site name (the value preceding.firebaseapp.comand.web.appand usually the Firebase project ID).For mobile apps:
If the Android package name or iOS bundle ID is present in the request, then the
%APP_NAME%will be the app name used in the Play Store or App Store (respectively).Otherwise, the
%APP_NAME%will be the default Firebase Hosting site name (the value preceding.firebaseapp.comand.web.appand usually the Firebase project ID).
Note that if the lookup of the default Firebase Hosting site name fails, then the final fallback is to use the Firebase project ID as the
%APP_NAME%.
Visit the Cloud Functions for Firebase FAQ and Troubleshooting page for troubleshooting help and answers to common questions.
Visit the FCM troubleshooting & FAQ page for helpful tips and answers to more FAQs.
Go to the Cloud Storage documentation to learn more about the Changes for the default Cloud Storage bucket .
Go to the Cloud Storage documentation to learn more about the Changes for pricing plan requirements for Cloud Storage .
Here are some likely reasons for getting these errors:
The Cloud Storage for Firebase API is not enabled for your project.
You can check if the API is enabled in the Google Cloud console. Learn how to find enabled APIs in your project and how to enable them in this Google Cloud guide .
The required service account for Cloud Storage for Firebase has one of the following issues:
The service account is missing required permissions.
The service account has been deleted. Note that in the Firebase console, a missing service account might manifest as a failure to add required IAM permissions.
For these two service account issues, see the related FAQ on this page.
Firebase uses service accounts to operate and manage services without sharing user credentials. When you create a Firebase project, you might notice that a number of service accounts are already available in your project.
The required service account for Cloud Storage for Firebase is scoped to your project and is named:service- PROJECT_NUMBER @gcp-sa-firebasestorage.iam.gserviceaccount.com .
If you used Cloud Storage for Firebase before September 19, 2022, you may see an additional service account on previously-linked Cloud Storage buckets named:firebase-storage@system.gserviceaccount.com . This old service account is no longer supported as of September 19, 2022.
You can view all service accounts for your project in the Service accounts tab of the Firebase console.
If you deleted the required service account or it's not present in your project, you can do one of the following to add the service account.
In the Firebase console, a missing service account might manifest as a failure to add required IAM permissions.
(Recommended) Automated : Use the
AddFirebaseREST endpoint to re-import your bucket into Firebase. You only need to call this endpoint once, not once for each linked bucket.Manual : Follow the steps in Creating and managing service accounts .
Following that guide, add a service account with the IAM role
Cloud Storage for Firebase Service Agentand service account name:service- PROJECT_NUMBER @gcp-sa-firebasestorage.iam.gserviceaccount.com.
We strongly discourage removing the service account because this may block access to your Cloud Storage buckets from your apps. To remove the service account from your project, follow the instructions in Disabling a service account .
Visit the Crashlytics troubleshooting & FAQ page for helpful tips and answers to more FAQs.
Visit the Firebase Hosting FAQ and Troubleshooting page for answers to common questions.
Visit the Performance Monitoring troubleshooting & FAQ page for helpful tips and answers to more FAQs.
Visit the Remote Config troubleshooting & FAQ page for helpful tips and answers to more FAQs.
Visit the Test Lab troubleshooting page for helpful tips and answers to FAQs.
Firebase App Indexing is no longer the recommended way of indexing content for display as suggested results in Google Search App. This FAQ points to other useful developer products.
Universal Links are the recommended way of linking users directly from search results, websites and other apps to specific content within your app.
Android App Links are the recommended way of linking users directly from search results, websites and other apps to specific content within your app.
You might also be interested in the following options:
App Search : High-performance on-device search
App Actions : Let users launch and control Android apps with their voice, using Google Assistant.
Android Shortcuts : Provide users with quick methods to perform an action or access content in your app.