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
-
First, navigate to github, settings, and then developer settings.
-
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.
-
Select finish, and generate a new secret. Ensure that you copy this secret.
Creating a python venv and flask Web App.
- 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
-
Make a new directory, and touch two files called creds.json and webapp.py inside this.
-
Inside creds.json, add your credentials in a json format. See top of page for source code including sample creds.json file.
-
Next, add your flask web application code to webapp.py. See top of page for source code including sample webapp.py file.
-
Now, create your python venv with the commands below.
python3 -m venv venv
source venv/bin/activate
- 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
- Now that your webapp is started, all you have to do is access the IP at port 5000 that the webapp is broadcasting.