Using Flask - jwells24/Tech-Journal GitHub Wiki

Using a Flask Web App for Federated Identity with Github

  • Link to source code with webapp.py and creds.json: Here

Create a github Oauth Application

  1. First, navigate to github, settings, and then developer settings.

  2. Navigate to Oauth apps and create a new application. Make sure to set a good name, and set the host address and callback address to 127.0.0.1:5000 if you are using localhost.

  3. Select finish, and generate a new secret. Ensure that you copy this secret.

Creating a python venv and flask Web App.

  1. On ubuntu, install the necessary dependencies for python.
apt install python3-pip build-essential libffi-dev python3-dev python3-setuptools libssl-dev

apt install python3.10-venv htt

pip3 install virtualenvwrapper
  1. Make a new directory, and touch two files called creds.json and webapp.py inside this.

  2. Inside creds.json, add your credentials in a json format. See top of page for source code including sample creds.json file.

  3. Next, add your flask web application code to webapp.py. See top of page for source code including sample webapp.py file.

  4. Now, create your python venv with the commands below.

python3 -m venv venv

source venv/bin/activate
  1. Once inside your virtual environment, install some more dependencies and start the web app.
pip3 install wheel

pip3 install Flask

pip3 install pyOpenSSL

pip3 install requests_oathlib

python3 webapp.py
  1. Now that your webapp is started, all you have to do is access the IP at port 5000 that the webapp is broadcasting.