Skip to main content

Google Authentication for TurboGears2

Project description

About googleplusauth

googleplusauth is a Pluggable application for TurboGears2.

It aims at making easy to implement authentication and registration with Google in any TurboGears2 application.

Installing

googleplusauth can be installed both from pypi or from bitbucket:

pip install googleplusauth

should just work for most of the users

Plugging googleplusauth

In your application config/app_cfg.py import plug:

from tgext.pluggable import plug

Then at the end of the file call plug with googleplusauth:

plug(base_config, 'googleplusauth')

Googleplushaut Helpers

googleplusauth provides a helpers which will automatically generate the buttons and the javascript required to let your users log into your application using Google:

  • h.googleplusauth.login_button(client_id, scope=None, data_cookiepolicy=None, img_btn_login=None, remember=None)

    Places a login/registration button, automatically creates a new user if he never logged with google, otherwise simply logs him in.

    The client_id parameter is YOUR_CLIENT_ID.apps.googleusercontent.com

    The scope parameter is the permissions that the application will ask to google. By default those are only https://www.googleapis.com/auth/userinfo.email. For more scope: https://developers.google.com/oauthplayground/

    The data_cookiepolicy parameter indicate the domains for which to create sign-in cookies.

    The img_btn_login parameter indicate the button image url.

    The remember parameter can be used to log the user with an expiration date instead of using a session cookie, so that the session can last longer than the browser tab life.

This is the html of the button, if you want customize the button style:

<div id="button-container">
    <div id="google-login-button" style="cursor: pointer;" onclick="perform_google_login()">
        <img id="img-login" src='%(img_btn_login)s' alt='Google Login' />
    </div>
</div>

Available Hooks

googleplusauth makes available a some hooks which will be called during some actions to alter the default behavior of the appplications:

  • googleplusauth.on_registration(google_response, user) -> Runs when it is registering a new user from google

    login, permits to add or modify additional data to the user.

  • googleplusauth.on_login(google_response, user) -> Runs when user perform google login,

    permits to update the user data.

Google Id and Profile Picture

Users will have a new related entity called googleplusauth. Accessing user.googleplusauth it is possible to access the user user.googleplusauth.google_id and user.googleplusauth.profile_picture and more.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgapp-googlePlusAuth-0.0.3.tar.gz (11.9 kB view details)

Uploaded Source

File details

Details for the file tgapp-googlePlusAuth-0.0.3.tar.gz.

File metadata

File hashes

Hashes for tgapp-googlePlusAuth-0.0.3.tar.gz
Algorithm Hash digest
SHA256 68ca61a0304dcaa8f3e183f0d468ee53f7d48b8843a583371dc8faad60376d4b
MD5 3f3e7daa1656a40dbf6f47dc07150d15
BLAKE2b-256 32946ac98e06b9e2de7c64cfd009b2be4be42676922acb5f555e8c444eb8c5ad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page