PySaaS
  • ๐Ÿ‘‹Introduction
  • ๐ŸšงInstallation and Setup
    • ๐Ÿง Installation
    • ๐Ÿ‘ฏUser Authentication - Firebase
    • ๐Ÿ‘ฏUser Authentication - Supabase
    • ๐Ÿ’ฐSubscriptions - Lemon Squeezy
    • ๐Ÿ’ปBlog CMS - Notion
    • ๐Ÿ“ŠGoogle Analytics
    • ๐ŸงชTesting
  • ๐Ÿš—Deployment
    • Hosting Options
    • Generalized Instructions
  • โ‰๏ธTroubleshooting
    • ๐Ÿ”ฅFirebase Setup
    • Firebase - Setting up Custom Domain for Emails
    • Firebase - Customizing Reset Emails
    • ๐Ÿ‹Lemon Squeezy Setup
    • โ†”๏ธNGROK Setup
    • ๐Ÿ’ปNotion Setup
    • โฌ†๏ธUpdating Project from Pynecone to Reflex
Powered by GitBook
On this page
  • Firebase Setup
  • Authentication Method
  • Realtime Database
  • Firebase Environment Variables
  1. Installation and Setup

User Authentication - Firebase

Enable User Authentication and data storage with Firebase

PreviousInstallationNextUser Authentication - Supabase

Last updated 1 year ago

Firebase Setup

Detailed screenshots are in the Firebase Setup troubleshooting section if you get stuck at any point. Find them here Firebase Setup

You'll need a Firebase account to set up your user authentication system and real-time database. Create a account with Google if you don't already have one.

Once you're signed in to your account, create a new Project for your application. For this project, we'll be using Authentication and Realtime Database features. You can find these on the menu bar in your Firebase console.

Create a new app in your project. During the registration process, there will be a section to add the SDK to your app. This contains the information that you will need to transfer to the .env file. If you don't find it, you can find it this way:

  • Navigate to your Project Settings

  • Find the "Your apps" section and view the code under the SDK Setup and Configuration title

  • You should see a Firebase config within the code containing the following variables:

firebaseConfig = {
  apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: "",
  appId: "",
  measurementId: ""
};

The values of each of these variables will be filled out and unique to your project. We'll need these values to set up our environment variables in the following steps.

Authentication Method

Navigate to Authentication in the Firebase side menu. Click on the "Sign-in method" tab and enable Email/Password.

Realtime Database

Navigate to your real-time database in the Firebase side menu. Click on the "Data" tab and click the "+" button next to your project URL. Enter "users" as the key, and leave the value blank.

Click into the "Rules" tab, and configure read and write permissions for your users:

{
  "rules": {
    "users": {
      ".read": true,
      ".write": true,
      ".indexOn": "email",
    }
  }
}

The .indexOn rule allows to search for a specific user. When PySaaS looks up a user, it filters on the email and Firebase requires a rule to allow the database to index on that column.

Firebase Environment Variables

Gather the values from the previous step and match them to the following in your .env file:

# Firebase
FIREBASE_API_KEY=
FIREBASE_AUTH_DOMAIN=
FIREBASE_DB_URL=
FIREBASE_PROJECT_ID=
FIREBASE_STORAGE_BUCKET=
FIREBASE_MSG_SENDER_ID=
FIREBASE_APP_ID=
FIREBASE_MEASUREMENT_ID=

THIS IS NOT SECURE AND ONLY MEANS FOR TESTING. YOU SHOULD ENABLE VERY STRICT SECURITY WHEN DEPLOYING TO PRODUCTION. Read more here:

๐Ÿšง
๐Ÿ‘ฏ
Firebase
Firebase Database Security