OAuth Login Implementation Examples using rauth via Bottle.py
System Packages:
- For Python packages:
python-setuptools
pip
virtualenv
Python Packages:
bottle
rauth
- Install
python-setuptools
:sudo apt-get install python-setuptools
- Install
pip
:sudo easy_install -U pip
- Install
virtualenv
:sudo pip install -U virtualenv
- Clone the repository:
git clone https://github.com/ejelome/oauth-login-implementation-examples-using-rauth-via-bottle.py
- Go to the directory:
cd oauth-login-implementation-examples-using-rauth-via-bottle.py
- Create a virtualenv:
virtualenv venv
- Activate virtualenv:
source venv/bin/activate
- Install remaining prerequisites (
bottle
andrauth
):pip install -r requirements.txt
In order to make the OAuth APIs work in our local machine, we need to modify the hosts file and pretend we're visiting an online URI:
- When testing Facebook and Twitter examples, make sure that the local address (
127.0.0.1
) points tomydomain.tld
- When testing the Google example, the
mydomain.tld
won't work since Google seem to know that it's an invalid URI - We can solve these issues by setting 2 aliases for the
127.0.0.1
address
- Open the hosts file:
sudo gedit /etc/hosts
- Add the following line:
127.0.0.1 mydomain.tld
- Execute one of the following:
python oauth2-facebook.py # Facebook
python oauth1-twitter.py # Twitter
python oauth2-google.py # Google
- Open a browser and go to: http://localhost:8000
- To Login:
- Click Log in using xyz, where xyz is either Facebook, Twitter, or Google
- Or go to: http://localhost:8000/login
- More detailed information are included in each of the executable files (there are also in the
config.py
file) - You can change the OAuth API settings on
config.py
file - You can change other configurations on the
config.py
file - Coding conventions are based on PEP 8 to make sure that you're also seeing good code examples
- The examples were done as minimal as possible so you can get a better understanding of OAuth and how simple it is
- Happy coding! :)
See: CHANGELOG