跳到主要内容

Firebase

Here is a step-by-step guide on how to set up your Firebase project, complete with images and descriptions.

1. Setup the clientId and keys

The first step is to locate your project's configuration details, including your clientId and API keys. These are essential for connecting your application to Firebase services. You can find them in your project settings in the Firebase console.

In your Firebase project settings, you can find your Web API Key and under the "Your apps" section, you'll see the clientId for each app you've added.

Follow this link:

console.cloud

20251124220038

2. Enable Google login

To allow users to sign in to your application using their Google accounts, you need to enable the Google sign-in provider in the Firebase Authentication settings.

console.firebase

20251124220057

also need Web client ID and WEB client secret, you can get it from first step.

20251124220112

3. Add domain to login

For security reasons, Firebase only allows sign-ins from domains that you explicitly authorize. You need to add the domain where your application is hosted to the list of authorized domains.

Still in the "Sign-in method" tab of the Authentication section, scroll down to "Authorized domains" and click "Add domain" to enter your application's domain.

20251124220132

4. Set JDK admin

To perform administrative tasks from a privileged environment (like a server), you need to use the Firebase Admin SDK. This requires a service account with the necessary permissions. You can generate a private key for this service account in the project settings.

Go back to "Project settings," select the "Service accounts" tab, and then click "Generate new private key." This will download a JSON file containing your service account credentials, which you can use to initialize the Admin SDK in your server-side code (e.g., Java, Node.js, Python).

20251124220149

  1. Config the Rule

20251124220202

// 登录用户即可读写所有数据
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
协议
本作品代码部分采用 Apache 2.0协议 进行许可。遵循许可的前提下,你可以自由地对代码进行修改,再发布,可以将代码用作商业用途。但要求你:
  • 署名:在原有代码和衍生代码中,保留原作者署名及代码来源信息。
  • 保留许可证:在原有代码和衍生代码中,保留Apache 2.0协议文件。
本作品文档部分采用 知识共享署名 4.0 国际许可协议 进行许可。遵循许可的前提下,你可以自由地共享,包括在任何媒介上以任何形式复制、发行本作品,亦可以自由地演绎、修改、转换或以本作品为基础进行二次创作。但要求你:
  • 署名:应在使用本文档的全部或部分内容时候,注明原作者及来源信息。
  • 非商业性使用:不得用于商业出版或其他任何带有商业性质的行为。如需商业使用,请联系作者。
  • 相同方式共享的条件:在本文档基础上演绎、修改的作品,应当继续以知识共享署名 4.0国际许可协议进行许可。