access_token_uri = 'https://accounts.google.com/o/oauth2/token'
redirect_uri = 'http://mysite/login/google/auth'
params = urllib.parse.urlencode({'code': request.GET['code'], 'redirect_uri':
    redirect_uri, 'client_id': XXXXX_your_google_key, 'client_secret':
    XXXXX_your_google_secret, 'grant_type': 'authorization_code'})
headers = {'content-type': 'application/x-www-form-urlencoded'}
resp, content = parser.request(access_token_uri, method='POST', body=params,
    headers=headers)
token_data = jsonDecode(content)
resp, content = parser.request(
    'https://www.googleapis.com/oauth2/v1/userinfo?access_token={accessToken}'
    .format(accessToken=token_data['access_token']))
google_profile = jsonDecode(content)
return HttpResponseRedirect('/dashboard')
Python Oauth2 — войдите через Google