Public Member Functions | Private Member Functions | Static Private Attributes
tornado.auth.GoogleOAuth2Mixin Class Reference
Inheritance diagram for tornado.auth.GoogleOAuth2Mixin:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def get_auth_http_client
def get_authenticated_user

Private Member Functions

def _on_access_token

Static Private Attributes

string _OAUTH_ACCESS_TOKEN_URL = "https://accounts.google.com/o/oauth2/token"
string _OAUTH_AUTHORIZE_URL = "https://accounts.google.com/o/oauth2/auth"
 _OAUTH_NO_CALLBACKS = False
string _OAUTH_SETTINGS_KEY = 'google_oauth'

Detailed Description

Google authentication using OAuth2.

In order to use, register your application with Google and copy the
relevant parameters to your application settings.

* Go to the Google Dev Console at http://console.developers.google.com
* Select a project, or create a new one.
* In the sidebar on the left, select APIs & Auth.
* In the list of APIs, find the Google+ API service and set it to ON.
* In the sidebar on the left, select Credentials.
* In the OAuth section of the page, select Create New Client ID.
* Set the Redirect URI to point to your auth handler
* Copy the "Client secret" and "Client ID" to the application settings as
  {"google_oauth": {"key": CLIENT_ID, "secret": CLIENT_SECRET}}

.. versionadded:: 3.2

Definition at line 977 of file auth.py.


Member Function Documentation

def tornado.auth.GoogleOAuth2Mixin._on_access_token (   self,
  future,
  response 
) [private]
Callback function for the exchange to the access token.

Definition at line 1036 of file auth.py.

Returns the `.AsyncHTTPClient` instance to be used for auth requests.

May be overridden by subclasses to use an HTTP client other than
the default.

Definition at line 1045 of file auth.py.

def tornado.auth.GoogleOAuth2Mixin.get_authenticated_user (   self,
  redirect_uri,
  code,
  callback 
)
Handles the login for the Google user, returning a user object.

Example usage::

    class GoogleOAuth2LoginHandler(tornado.web.RequestHandler,
                           tornado.auth.GoogleOAuth2Mixin):
@tornado.gen.coroutine
def get(self):
    if self.get_argument('code', False):
        user = yield self.get_authenticated_user(
            redirect_uri='http://your.site.com/auth/google',
            code=self.get_argument('code'))
        # Save the user with e.g. set_secure_cookie
    else:
        yield self.authorize_redirect(
            redirect_uri='http://your.site.com/auth/google',
            client_id=self.settings['google_oauth']['key'],
            scope=['profile', 'email'],
            response_type='code',
            extra_params={'approval_prompt': 'auto'})

Definition at line 1001 of file auth.py.


Member Data Documentation

string tornado::auth.GoogleOAuth2Mixin::_OAUTH_ACCESS_TOKEN_URL = "https://accounts.google.com/o/oauth2/token" [static, private]

Definition at line 996 of file auth.py.

string tornado::auth.GoogleOAuth2Mixin::_OAUTH_AUTHORIZE_URL = "https://accounts.google.com/o/oauth2/auth" [static, private]

Definition at line 995 of file auth.py.

Definition at line 997 of file auth.py.

string tornado::auth.GoogleOAuth2Mixin::_OAUTH_SETTINGS_KEY = 'google_oauth' [static, private]

Definition at line 998 of file auth.py.


The documentation for this class was generated from the following file:


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Wed Sep 13 2017 03:18:20