firebase-auth-ui

This package will help you to add authentication system and modern UI for your desktop based Python apps in a couple of seconds.


License
Other
Install
pip install firebase-auth-ui==0.0.3

Documentation

Firebase Authentication in Python Using Tkinter

This module will help you to add authentication system in your desktop based Python apps in a couple of seconds. Just add this repository in the root folder of your project and write couple of lines to use Firebase authentication system in your python apps.

Contributors Contributors Members Stars

MIT License "FirebaseandPython" "Tkinter" "EZTranslation" "PriomDeb"


Table of Contents
  1. Install Required Dependencies
  • Documentation
  • Language and Tools
  • Contact
  • Screenshots of the UI
  • Dependencies

    Install these Dependencies from your terminal. I normally use my PyCharm terminal to install the libraries so the libraries are only installed for my working project and not for all project. If you want you can install from your Git Bush/Windows CMD/Powershell.

    1. Install Tkinter

    pip install tk

    Please follow the current installation process of Tkinter from online.

    2. Install Firebase Library for Python

    pip install pyrebase4

    We will be using pyrebase4 instead of other pyrebase libraries.

    3. Install Pillow

    pip install Pillow

    We install Pillow to process .png images for UI.

    4. Install Pygame

    pip install pygame

    We are installing pygame to add some audios for click and error in our authentication app. If you don't want to add then you can just ignore to install this library.

    5. Install Pyglet

    pip install pyglet

    We are installing this library to add third-party/downloaded fonts in our app.

    Documentation

    🌵Clone This Repository

    • Open Git bash
    • Change the current working directory to the location where you want the cloned directory. Basically your main python app project directory.
    • Right clik in your Git Bash and paste the below code.
    $ git clone https://github.com/PriomDeb/Firebase-Authentication-in-Python-Using-Tkinter.git

    You can clone or simply download this repository as a .zip file. But make sure you put these folders and scripts in your project's root directory.

    Scripts
    pyrebaseAuthentication.py
    tkinterLoginUI.py
    app.py
    Folders
    authenticationUI
    fonts

    🐍 Just a few lines of python code to implement authentication

    Add these lines one by one in your python script from where your app's function will be called and your Firebase Authentication in Python using Tkinter is done!


    First import these 3 required libraries

    from tkinter import *
    from pyrebaseAuthentication import FirebaseAuthenticationAPI
    from tkinterLoginUI import DrawAuthentication

    Then create a object of FirebaseAuthenticationAPI()

    firebaseAuth = FirebaseAuthenticationAPI()

    Next create a Firebase Project

    • Go to https://console.firebase.google.com/
    • Click "Add project"
    • Give your project name (Any name you want) and click Continue
    • Keep Google Analytics as same as it (Default is Enabled) given and click Continue
    • Select "Default Account for Firebase" and click Create project
    • Wait for a couple of seconds to get your project ready and when it is ready click Continue
    • A dashboard of Project Overview will be opened and you will see iOS+, Android and Web
    • Click on the Web which icon is </>
    • Give an app name and don't select "Also set up Firebase Hosting for this app. Learn more" then click Register app
    • Now you will see Add Firebase SDK
    • Look throgh the SDK codes that is generated by Firebase
    • You will see a const variable firebaseConfig which is your configuration values to use Firebase Authentication
    • Copy the entire firebaseConfig values
    • apiKey: "XXxxXxX00XXxxx-xxxxX0XXXx0XxxxxxXXXXxxx",
      authDomain: "xxx-xx-xxxxx.xxxxxxxxxxx.com",
      projectId: "xxx-xx-xxxxx",
      storageBucket: "xxx-xx-xxxxx.xxxxxxxx.com",
      messagingSenderId: "xxxxxxxxxxxx",
      appId: "x:xxxxxxxxxxxx:web:xxxxxxxxxxxxxxxxxxxxxx",
      measurementId: "G-XXXXXXXXXX"}
      
    • Click Continue to console
    • Open your python script and create a dictionary variable firebase_config and paste the values like the given format
    • firebase_config={"apiKey": "XXxxXxX00XXxxx-xxxxX0XXXx0XxxxxxXXXXxxx",
      "authDomain": "xxx-xx-xxxxx.xxxxxxxxxxx.com",
      "projectId": "xxx-xx-xxxxx",
      "storageBucket": "xxx-xx-xxxxx.xxxxxxxx.com",
      "messagingSenderId": "xxxxxxxxxxxx",
      "appId": "x:xxxxxxxxxxxx:web:xxxxxxxxxxxxxxxxxxxxxx",
      "measurementId": "G-XXXXXXXXXX",
      "databaseURL": ""
      }
      # Copy this format exactly and DON"T FORGET TO KEEP "databaseURL":"", an empty string
      # Keep databaseURL value an empty string
      
      # See I have put the keys inside ""
      # You need to put all the keys inside "" as python only accepts this format in its dictionary data types
    • Don't forget to add "databaseURL":"" like this, keep the value of "databaseURL" = empty string
    • Go to your Firebase Project Overview/Dashboard and last one thing need to configure to use Firebase Authentication
    • Click Build from left side menu
    • Click Authentication
    • Click Get Started
    • From Sign-in method select Email/Password and Enable it
    • Click Save

    That's all from Firebase console.


    Initialize Firebase

    firebaseAuth.initialize_firebase(firebase_config)

    Write a function like this exact format and call it

    def authentication_to_enter_the_app():
        read_authentication = firebaseAuth.check_authentication()
        uui, display_name, signed_in = read_authentication
    
        if not signed_in:
            login = DrawAuthentication()
            login.drawLogin()
    
            if login.authentication_success and login.authentication_email_verified and login.authentication_correct_email_password:
                uui, display_name, signed_in = firebaseAuth.check_authentication()
    
                # Call Your App Function 
                # Anything code that your want to run after Firebase Authentication is complete successfully
                my_tkinter_app(display_name)
        else:
            # Call App Function
            # Anything code that your want to run after Firebase Authentication is complete successfully
            my_tkinter_app(display_name)
    
    authentication_to_enter_the_app()

    bada bim bada boom!



    Full code to implement sign in and sign system in your python app using Firebase and Tkinter

    from tkinter import *
    from pyrebaseAuthentication import FirebaseAuthenticationAPI
    from tkinterLoginUI import DrawAuthentication
    
    # Put all your code inside this function or put the main function calls which is necessary to run your app
    # 
    def my_app(display_name):
        print(f"Hi, {display_name}!")
    
    firebase_config={"apiKey": "XXxxXxX00XXxxx-xxxxX0XXXx0XxxxxxXXXXxxx",
    "authDomain": "xxx-xx-xxxxx.xxxxxxxxxxx.com",
    "projectId": "xxx-xx-xxxxx",
    "storageBucket": "xxx-xx-xxxxx.xxxxxxxx.com",
    "messagingSenderId": "xxxxxxxxxxxx",
    "appId": "x:xxxxxxxxxxxx:web:xxxxxxxxxxxxxxxxxxxxxx",
    "measurementId": "G-XXXXXXXXXX"}
    
    firebaseAuth = FirebaseAuthenticationAPI()
    firebaseAuth.initialize_firebase(firebase_config_values)
    
    def authentication_to_enter_the_app():
        read_authentication = firebaseAuth.check_authentication()
        uui, display_name, signed_in = read_authentication
    
        if not signed_in:
            login = DrawAuthentication()
            login.drawLogin()
    
            if login.authentication_success and login.authentication_email_verified and login.authentication_correct_email_password:
                uui, display_name, signed_in = firebaseAuth.check_authentication()
                # Call App Function
                my_app(display_name)
        else:
            # Call App Function
            my_app(display_name)
    
    
    authentication_to_enter_the_app()

    If you clone this entire repository, you will see a app.py script where I showed how the implementation is work and this is very simple. By writing a couple of lines you can implement sign in and sign out in your python apps. Basically for python desktop apps.

    That's how you add sign in and sign out using Firebase in Python in the simplest way!


    Languages and Tools

    figma firebase git python pycharm


    Contact

    Mail

    priom@priomdeb.com

    diskaouapps@gmail.com

    http://priomdeb.com

    🌵 Stay peace and keep coding!

    Screenshots of the UI

    login-UI-min reset-Password-min sign-Up-UI-min terms-min verify-Email-min internet-Connection-min