Skip to main content

Log in screen for Kivy applications using Google Firebase.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

firebaseloginscreen-1.0.10.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

firebaseloginscreen-1.0.10-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file firebaseloginscreen-1.0.10.tar.gz.

File metadata

  • Download URL: firebaseloginscreen-1.0.10.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for firebaseloginscreen-1.0.10.tar.gz
Algorithm Hash digest
SHA256 da4ce89c1ed8dab43ea9ee95c9469f64e753066ffb3330c32bed01172af9296c
MD5 122a17a45a39412081aabc1940dc0786
BLAKE2b-256 5487af39f9917e32ff74e571c2424e8af7f45d027bd57d8d474429c5c9892437

See more details on using hashes here.

File details

Details for the file firebaseloginscreen-1.0.10-py3-none-any.whl.

File metadata

  • Download URL: firebaseloginscreen-1.0.10-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for firebaseloginscreen-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 4981b65ba27c4243013808f3f8f808faea51c76d4878b55e55c4858203b435dd
MD5 5328f8f3bef3d27d93b46714cdaa2a46
BLAKE2b-256 9b0729b02cf6f295b385e1590f0beffd3690aae5ca9b20178fbccaff142d1809

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page