Skip to main content

FirebaseLoginScreen

Complete login screen with backend included for Kivy apps using Firebase for user authentication.

This package lets you essentially drop a functional login screen into your app within seconds.

Installation

pip install firebaseloginscreen

Features

  • Create account
  • Email verification for new accounts
  • Sign in to account
  • Log out of account
  • Reset password
  • Automatically signs users in upon app launch if an account has already been created.

Usage

Psst. Want to just see a full example? Check out main.py and main.kv in the examples directory.

Add the FirebaseLoginScreen widget to your ScreenManager

In the kv file where you want to use the login screen, import the FirebaseLoginScreen widget:

#:import FirebaseLoginScreen firebaseloginscreen.firebaseloginscreen.FirebaseLoginScreen

Then add the FirebaseLoginScreen widget to your ScreenManager class, wherever that may be. Here's a snippet of the code you should add to your ScreenManager:

    # ---- This should be within a ScreenManager
    FirebaseLoginScreen:
        id: firebase_login_screen
        name: "firebase_login_screen"
        debug: True
        remember_user: True
        require_email_verification: True
        web_api_key: "your_web_api_key_from_firebase" # Found in Firebase -> Project Settings -> Web API Key
        background: "background.jpg"
        on_login_success:
            # Defining this function lets you program what to do when the
            # user has logged in (probably you'll want to change screens)!
            # Get the important user info
            if self.login_state == 'in': app.user_localId = self.localId
            if self.login_state == 'in': app.user_idToken = self.idToken
            if self.login_state == "in": print("User logged in")

            if self.login_state == 'out': print("User logged out")
    # ---- Other screens in your app should be down here (below the FirebaseLoginScreen)

Make sure the FirebaseLoginScreen is the first screen in your ScreenManager.

Variables you can set

Variable Name Required? Description Default Type
web_api_key Yes Your Firebase project's web api key. "" String
on_login_success Yes This function is fired when the user successfully logs in OR out. You can specify different things to do by checking if self.login_state == 'in' or self.login_state == 'out' to call different functions when the user logs in or out. None Function(s)
remember_user No Will remember the last user to sign in and automatically sign them in when they open the app. True Boolean
require_email_verification No Sends new users a verification email before they can sign in. True Boolean
background No The path to an image that will be the background for the login screen. "" String
debug No Will print a bunch of helpful output. False Boolean

Need help figuring out the setup related to Firebase? Check out these instructions.

Notes from the author

You should define the on_login_success function to execute whatever code you want once a user has logged in. Probably you'll want to 1) Retrieve some data from Firebase and 2) switch to a different screen in your ScreenManager.

If a user has already signed in, it will store their login data and automatically sign them in the next time around. In this case, the login screens will not be shown, and your app will immediately do whatever you have coded it to do in the on_login_success function of the FirebaseLoginScreen.

Typically, when making requests to your database to get data for your user, you identify the user by their localId. You can use the idToken to authenticate a user's request to the database if you have set up Firebase Rules. Both of these variables are automatically retrieved for you by FirebaseLoginScreen.

Need to allow your users to sign out? To do so, reference your FirebaseLoginScreen widget (using an id) and call the .log_out() function. Then have your ScreenManager switch to the FirebaseLoginScreen to allow your user to sign in again.

If your app takes a long time to start up, you may need to set the web_api_key from python instead of in the kv language. You need to set it in the on_start method of your App class. Haven't fully characterized this race condition yet.

Future Features

  • Boolean SMS Verification (for phone sign ins)
  • Sign in method choice
    • email, phone

Metadata

Release files for firebaseloginscreen 1.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for firebaseloginscreen 1.0.10
File Size Uploaded
firebaseloginscreen-1.0.10.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for firebaseloginscreen 1.0.10
File Interpreter ABI Platform
firebaseloginscreen-1.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 24.6 kB

Release files / firebaseloginscreen-1.0.10.tar.gz

Download URL firebaseloginscreen-1.0.10.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
da4ce89c1ed8dab43ea9ee95c9469f64e753066ffb3330c32bed01172af9296c
BLAKE2b-256 checksum
How to use checksums
5487af39f9917e32ff74e571c2424e8af7f45d027bd57d8d474429c5c9892437
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.6

Release files / firebaseloginscreen-1.0.10-py3-none-any.whl

Download URL firebaseloginscreen-1.0.10-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4981b65ba27c4243013808f3f8f808faea51c76d4878b55e55c4858203b435dd
BLAKE2b-256 checksum
How to use checksums
9b0729b02cf6f295b385e1590f0beffd3690aae5ca9b20178fbccaff142d1809
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.6

Release history Release notifications | RSS feed

This release

1.0.10 This release

2 release files

1.0.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page