An open API service indexing awesome lists of open source software.

https://github.com/app-generator/flask-social-login

Flask Social Login - Open-Source Seed Project | AppSeed
https://github.com/app-generator/flask-social-login

appseed-sample flask social-login

Last synced: about 1 year ago
JSON representation

Flask Social Login - Open-Source Seed Project | AppSeed

Awesome Lists containing this project

README

          

# [Flask Social Login](https://blog.appseed.us/flask-social-login-with-github/)

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

- Up-to-date [dependencies](./requirements.txt): **Flask 2.0.1**
- `OPENID` Social login over [Flask Dance](https://pypi.org/project/Flask-Dance/)
- Github Login
- Google Login (WIP)
- Support via **Github** (issues tracker) and [Discord](https://discord.gg/fZC6hup).


![Flask Social Login - Free sample provided by AppSeed.](https://user-images.githubusercontent.com/51070104/135398234-06a43c1a-cd0a-45ad-accc-de45061d8945.png)


## Build from sources

> **Step #1** - Clone sources (this repo)

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


> **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
$ # Install requirements
$ 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** - [Creating an OAuth App](https://docs.github.com/en/developers/apps/building-oauth-apps/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)

```bash
$ # 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)

```bash
$ 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:

```bash
< PROJECT ROOT >
|
|-- app/
| |-- static/
| | |-- # 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

- Free [Admin Dashboards](https://appseed.us/admin-dashboards/open-source) - index provided by AppSeed
- [Flask User Authentication](https://blog.appseed.us/flask-user-authentication-free-sample/) - blog article (includes a free sample)


---
[Flask Social Login](https://blog.appseed.us/flask-social-login-with-github/) - Free sample provided by **AppSeed [App Generator](https://appseed.us/app-generator)**.