Go To Dashboard

Python


This guide will show you how to implement the user authentication in a Python application. For this tutorial, we will use the Python demo from GitHub and show you step by step how to run it.

Prerequisites

This tutorial assumes you have:

  • python 2.7 and up
  • pip

Setup Your Dashboard

Get your credentials and whitelist your application domain as explained in this section. This is a mandatory step to successfully implement and run the demo.

Start with Auth Page (IDX) demo

  1. You can clone the Auth Page demo repository on your system using below commands:

    With SSH

    git clone git@github.com:LoginRadius/login-page-demos.git

    With https

    git clone https://github.com/LoginRadius/login-page-demos.git
  2. Now move to the directory Python demo by running the following command using the terminal

cd login-page-demo/python-idx-demo/Demo/

This is the file structure you will get in the Python demo, let's see what each file does

  • static folder - Contains all the CSS and JS and images to create UI for the test application.

  • template folder - Contains the HTML code for profile and Login page.

  • LoginRadius folder - contains the LoginRadius Python SDK codes needed to run the authentication demo

+demo/
|-- app.py
|-- auth.py
|-- lr.py
|-- +static/
|-- |--css/
|-- |--images/
|-- |--js/
|-- +templates
|-- |--index.html
|-- |--profile.html
|-- |--resetpassword.html
|-- +LoginRadius/
  1. You need to add your LoginRadius credentials in the demo app to communicate with LoginRadius SDK

Server Side: python-idx-demo/Demo/lr.py

API_KEY = "<Enter LoginRadius API Key>"
API_SECRET = "<Enter LoginRadius API secret"

Client Side: python-idx-demo/Demo/static/js/options.js

commonOptions.apiKey = "<LoginRadius API Key";
commonOptions.appName = "<App Name>";
  1. Running application

Run the below commands in the terminal from the root folder of the application

pip install flask requests pbkdf2 cryptography && cd python-idx-demo/Demo

This command will install all the required dependency to run the python demo and change the directory to Demo folder from where your application will be served.

Once all the dependencies have been installed run the application

python app.py

Now you can see application running in the http://localhost:5000, Once you click on login button it will redirect you to auth page.

python-app

Features implemented in demo

  • Login with Auth Page (IDX)
  • Registration with Auth Page (IDX)
  • Email Verification
  • Forgot Password
  • Reset Password

Discover More

Discover More on

How To Guides

Edit on GitHub