-
Go to google cloud console -> Your Project -> credentials & introduce the following settings variables with the values from the client credentials page:
GAPPS_CLIENT_ID
,GAPPS_CLIENT_SECRET
,GAPPS_REDIRECT_URI
,GAPPS_TOKEN_URI
,GAPPS_AUTH_URI
&GAPPS_SCOPE
-
Define two more settings variables
GAPPS_LOGIN_SUCCESS_HANDLER
&GAPPS_USER_FUNCTION
referring to the function locations in your app. -
pip install https://github.com/Aplopio/django_gapps_oauth2_login/archive/v0.9.7.6.tar.gz
-
Add
django_gapps_oauth2_login
to INSTALLED_APPS in settings.py -
Update urls.py by adding following entry:
(r'^oauth2/', include('django_gapps_oauth2_login.urls'))
-
run
python manage.py syncdb
-
Run testcases,
python manage.py test django_gapps_oauth2_login
Oauth2 Login module has two views login_begin & auth_required.
login_begin - this view is called by the google markeplace url ( /oauth2/login/?domain=${DOMAIN_NAME}
)
domain
is optional parameter if it is present it will be considered as Hosted Domain for GAppsaction
is optional paramater which is passed on to GAPPS_USER_FUNCTION auth_required - this view is called by google after proper authentication ( we give it asredirect_uri
to google:/oauth2/oauth2callback
)
For the first time when a user installs your google app, it lands to login_begin
& after taking appropriate authentication access, it get's redirected to auth_required
view.
Once the user is created or referenced, GAPPS_USER_FUNCTION
. is called
Once the user is authenticated, GAPPS_LOGIN_SUCCESS_HANDLER
. is called
All you will have to hook up appropriate functions for these signals
More here: http://wimprint.com/~vivek/log-52 and https://developers.google.com/api-client-library/python/guide/aaa_oauth