Skip to content

app-generator/sample-flask-auth-social

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open-source Flask Sample built on top of flask-dance library. The project implements the social login for Github and Twitter - Originally coded by TestDriven.IO.


✨ Features:

  • Up-to-date dependencies
  • OPENID Social login over Flask Dance
    • Github
    • Twitter
  • SQLite Persistence, SQLAlchemy ORM
  • Free Support: email and Discord (1k+ community).

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/sample-flask-auth-social.git
$ cd sample-flask-auth-social

👉 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

$ 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 - (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"

👉 Github Setup - Create an OAuth App

  • 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

👉 Twitter Setup - Create an OAuth App

  • SignIN to Twitter
  • Access Developer Section -> https://developer.twitter.com/en/portal/projects-and-apps
  • Create a new APP
  • Edit User authentication settings
    • Check OAuth 1.0a
    • (mandatory) HomePage: https://www.localhost:5000
    • (mandatory) Authorization callback URL: https://127.0.0.1:5000/login/twitter/authorized

👉 Update Environment - Rename .env.sample to .env and edit the file

  • For GITHUB Login
    • GITHUB_ID - value provided by Github Setup
    • GITHUB_SECRET - value provided by Github Setup
  • For TWitter Login
    • TWITTER_ID - value provided by Twitter Setup
    • TWITTER_SECRET - value provided by Twitter Setup

👉 Start the project Using HTTPS

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

Important: The --cert=adhoc will force the https protocol


✨ Account Details

Once the user is authenticated, all available information can be accessed via /ping route:

Github sample (truncated): https://localhost:5000/ping

{
  "avatar_url": "https://avatars.githubusercontent.com/u/51070104?v=4",
  "bio": "App Generator and Boilerplate Code.",
  "blog": "https://appseed.us/app-generator",
  "company": "AppSeed",
  "created_at": "2019-05-27T04:55:15Z",
  "followers": 777,
  "public_repos": 495,
  "url": "https://api.github.com/users/app-generator"
}

✨ Sample SShots

Successfull Github Login

Successfull Github Login


Successfull TWitter Login

Successfull Twitter Login


Github account information

Github account info - JSON format.


✨ Credits



Flask Social Login (Twitter & Github) - Free sample provided by AppSeed App Generator.