https://github.com/app-generator/sample-flask-auth-social
Flask Social Login - Github & Twitter | AppSeed
https://github.com/app-generator/sample-flask-auth-social
appseed-sample flask-sample oauth2
Last synced: 2 months ago
JSON representation
Flask Social Login - Github & Twitter | AppSeed
- Host: GitHub
- URL: https://github.com/app-generator/sample-flask-auth-social
- Owner: app-generator
- License: other
- Created: 2022-01-29T09:59:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-04T15:05:21.000Z (almost 2 years ago)
- Last Synced: 2025-03-11T05:55:55.125Z (2 months ago)
- Topics: appseed-sample, flask-sample, oauth2
- Language: Python
- Homepage: https://blog.appseed.us/flask-social-authentication-github-twitter/
- Size: 44.9 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# [Flask Social Login (Twitter & Github)](https://blog.appseed.us/flask-social-authentication-github-twitter/)
Open-source Flask Sample built on top of `flask-dance` library. The project implements the **[social login for Github and Twitter](https://blog.appseed.us/flask-social-authentication-github-twitter/)** - Originally coded by _[TestDriven.IO](https://github.com/testdrivenio/flask-social-auth)_.
> ✨ Features:
- `Up-to-date dependencies`
- `OPENID` Social login over [Flask Dance](https://pypi.org/project/Flask-Dance/)
- **Github**
- **Twitter**
- `SQLite` Persistence, `SQLAlchemy` ORM
- Free [Support](https://appseed.us/support): email and [Discord](https://discord.gg/fZC6hup) (1k+ community).

## ✨ Build from sources
> 👉 **Step #1** - Clone sources (this repo)
```bash
$ # 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
```bash
$ # 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
```bash
$ pip3 install -r requirements.txt
```
> 👉 **Step #4** - Set Up Environment
```bash
$ # 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)
```bash
$ # 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](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-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](https://developer.twitter.com/en/portal/projects-and-apps)
- 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
```bash
$ 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`
```json
{
"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 `TWitter` Login

> `Github` account information

## ✨ Credits
- Originally coded by [TestDriven.IO](https://github.com/testdrivenio/flask-social-auth)
- [Flask-Dance](https://flask-dance.readthedocs.io/en/latest/) - The library that implements the hard work
---
[Flask Social Login (Twitter & Github)](https://blog.appseed.us/flask-social-authentication-github-twitter/) - Free sample provided by **AppSeed [App Generator](https://appseed.us/app-generator)**.