Skip to main content

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

Project description

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"


Documentation

🐍 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 firebase_auth_ui import tkinterLoginUI.DrawAuthentication
from firebase_auth_ui import pyrebaseAuthentication.FirebaseAuthenticationAPI

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

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

firebase_auth_ui-0.0.1.tar.gz (33.8 MB view hashes)

Uploaded Source

Built Distribution

firebase_auth_ui-0.0.1-py3-none-any.whl (33.8 MB view hashes)

Uploaded Python 3

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