bottle-auth
Bottle plugin authentication, support with Google, Twitter and Facebook
Example
from bottle import Bottle, request, run
from bottle.ext import auth
from bottle.ext.auth.decorator import login
from bottle.ext.auth.social.facebook import Facebook
from pprint import pformat
facebook = Facebook('fb-key', 'fb-secret',
'http://127.0.0.1:3333/', 'email')
app = Bottle()
plugin = auth.AuthPlugin(facebook)
app.install(plugin)
@app.route('/')
@login()
def home():
user = auth.get_user(request.environ)
return "Home page {}".format(pformat(user))
run(app=app, host='0.0.0.0', port='3333', debug=True)
Application in production: https://github.com/avelino/mining/blob/master/mining/auth.py
Create project
- Sign into your Google Apps account in your browser
- Visit https://code.google.com/apis/console#access in the same browser
- On the left menu, Create a new Project
- To start, you don’t need any Services, so select the API Access tab rom the left menu and “Create an OAuth 2.0 client ID…”
- Fill out the Client ID form for a web application and use localhost:8000 as your hostname
Create project
- Sign into your Facebook account in your browser
- Visit https://developers.facebook.com/ in the same browser
- Click Apps > Create a New App in the navigation bar
- Enter Display Name, then choose a category, then click Create app
- Fill out the Client ID form for a web application and use localhost:8000 as your hostname