oauth2client.contrib.django_util.views module¶
This module contains the views used by the OAuth2 flows.
Their are two views used by the OAuth2 flow, the authorize and the callback view. The authorize view kicks off the three-legged OAuth flow, and the callback view validates the flow and if successful stores the credentials in the configured storage.
View to start the OAuth2 Authorization flow.
This view starts the OAuth2 authorization flow. If scopes is passed in as a GET URL parameter, it will authorize those scopes, otherwise the default scopes specified in settings. The return_url can also be specified as a GET parameter, otherwise the referer header will be checked, and if that isn’t found it will return to the root path.Parameters: request – The Django request object. Returns: A redirect to Google OAuth2 Authorization.
-
oauth2client.contrib.django_util.views.
oauth2_callback
(request)[source]¶ View that handles the user’s return from OAuth2 provider.
This view verifies the CSRF state and OAuth authorization code, and on success stores the credentials obtained in the storage provider, and redirects to the return_url specified in the authorize view and stored in the session.
Parameters: request – Django request. Returns: A redirect response back to the return_url.