Skip to content

app-generator/flask-social-login

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
app
 
 
 
 
 
 
 
 
 
 
 
 

Flask Social Login

Open-source Flask sample built on top of flask-dance library. The project showcases the social login for Github - Features:

  • Up-to-date dependencies: Flask 2.0.1
  • OPENID Social login over Flask Dance
    • Github Login
    • Google Login (WIP)
  • Support via Github (issues tracker) and Discord.

Flask Social Login - Free sample provided by AppSeed.


Build from sources

Step #1 - Clone sources (this repo)

$ # Clone the sources
$ git clone https://github.com/app-generator/flask-social-login.git
$ cd flask-social-login

Step #2 - Create a virtual environment

$ # Virtualenv modules installation (Unix based systems)
$ virtualenv env
$ source env/bin/activate
$
$ # Virtualenv modules installation (Windows based systems)
$ # virtualenv env
$ # .\env\Scripts\activate

Step #3 - Install dependencies

$ # Install requirements
$ pip3 install -r requirements.txt

Step #4 - Set Up Environment

$ # Set the FLASK_APP environment variable
$ (Unix/Mac) export FLASK_APP=run.py
$ (Windows) set FLASK_APP=run.py
$ (Powershell) $env:FLASK_APP = ".\run.py"

Step #5 - Creating an OAuth App (on Github)

  • SignIN to Github
  • Access Settings -> Developer Settings -> OAuth Apps
  • Edit your OAuth App
    • App Name
    • App Description
    • (mandatory) HomePage: https://localhost:5000
    • (mandatory) Authorization callback URL: https://localhost:5000/login/github/authorized
    • Generate a new secret key

Step #6 - Rename .env.sample to .env and edit the file

  • GITHUB_OAUTH_CLIENT_ID - value provided by Github (step #5)
  • GITHUB_OAUTH_CLIENT_SECRET - value provided by Github (step #5)

Step #7 - (optional) Enable DEBUG Environment (local development)

$ # Set up the DEBUG environment
$ (Unix/Mac) export FLASK_ENV=development
$ (Windows) set FLASK_ENV=development
$ (Powershell) $env:FLASK_ENV = "development"

Step #8 - Start the project (HTTPS)

$ flask run --cert=adhoc
$
$ # Access the app in browser: HTTPS://127.0.0.1:5000/

Code-base structure

The project has a super simple structure, represented as bellow:

< PROJECT ROOT >
   |
   |-- app/
   |    |-- static/
   |    |    |-- <css, JS, images>    # CSS files, Javascripts files
   |    |
   |    |-- templates/
   |    |    |
   |    |    |-- index.html           # Index File
   |    |    |-- login.html           # Login Page
   |    |    |-- register.html        # Registration Page
   |    |    
   |    |
   |   config.py                      # Provides APP Configuration 
   |  __init__.py                     # Bootstrap the project
   |
   |-- .env                           # Injects Github Credentials
   |-- requirements.txt
   |-- run.py
   |
   |-- ************************************************************************

Resources



Flask Social Login - Free sample provided by AppSeed App Generator.