Basic OAuth 2.0 Support for Web.py
Implement basic OAuth 2.0 support for web.py. Inspired by simpleauth.
-
Google (OAuth 2.0)
-
Doc:
-
Create App & Get client ID/Secret:
-
Scopes:
-
https://www.googleapis.com/auth/userinfo.profile: Userinfo - Profile -
https://www.googleapis.com/auth/userinfo.email: Userinfo - Email -
Reference: List of Google OAuth Scopes
-
-
-
Facebook (OAuth 2.0)
-
Doc:
-
Create App & Get client ID/Secret:
-
Scopes:
-
email: Provides access to the primary email address of the user in the email property. -
user_about_me: Provides access to the "About Me" section of the profile in the about property -
Reference: Permissions
-
-
- Web.py: see Web.py Install Guide to install web.py.
-
Create app & get client id/secret from providers. (Google: Google Cloud Console, Facebook: Facebook Developers)
-
Put
auth.pyin your project root dir, and also add your project root dir to sys path.auth.pyhandles OAuth 2.0 process for you, and you do not need to modify this script. -
In you main python script, create a request handler by subclassing
auth.handler. Set url routing and client id/secret. Please refer tologin.pyfor a complete example. -
You can run the example (remember to modify app id/secret and
callback_urifunction in the exmaple) by the following bash command:
$ python login.pyThis project is released in public domain, see UNLICENSE