Flask Social Login (Twitter & Github)
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
SQLite
Persistence,SQLAlchemy
ORM- Free Support: email and Discord (1k+ community).
β¨
Build from sources
π Step #1 - Clone sources (this repo)
$ # Clone the sources
$ git clone https://github.com/app-generator/flask-social-login-v2.git
$ cd flask-social-login-v2
π 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://localhost:5000
- (mandatory)
Authorization callback URL
:https://localhost:5000/login/twitter/authorized
- Check
π Update Environment - Rename.env.sample
to.env
and edit the file
- For GITHUB Login
GITHUB_ID
- value provided byGithub Setup
GITHUB_SECRET
- value provided byGithub Setup
- For TWitter Login
TWITTER_ID
- value provided byTwitter Setup
TWITTER_SECRET
- value provided byTwitter 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
account information
β¨
Credits
- Originally coded by TestDriven.IO
- Flask-Dance - The library that implements the hard work
Flask Social Login (Twitter & Github) - Free sample provided by AppSeed App Generator.