Google APIs OAuth Django

A library to help integrate Google OAuth 2.0 to your Django application. This library retrieves the necessary tokens you need to access the Google APIs your application is configured for.
Installation
pip install google-apis-oauth-django
Usage
Redirecting users to the login screen
from django.shortcuts import HttpResponseRedirect
import google_apis_oauth
def RedirectToOAuthPage(request):
oauth_url = google_apis_oauth.get_authorization_url(
JSON_FILEPATH,
SCOPES,
REDIRECT_URI,
True)
return HttpResponseRedirect(url)
Retreving and storing the credentials after successful login
import google_apis_oauth
def RedirectView(request):
try:
credentials = google_apis_oauth.get_crendentials_from_callback(
request,
JSON_FILEPATH,
SCOPES,
REDIRECT_URI
)
stringified_token = google_apis_oauth.stringify_credentials(
credentials)
...
...
except google_apis_oauth.exceptions.InvalidLoginException:
Loading and using the user credentials
import google_apis_oauth
from googleapiclient.discovery import build
creds, refreshed = google_apis_oauth.load_credentials(stringified_token)
service = build('calendar', 'v3', credentials=creds)
...
Example
You can refer to this blog for an example where this library is used.