-
-
Save wowkin2/dc30a3f12abc77f2afc750fbe3464d3b to your computer and use it in GitHub Desktop.
How to link django-social-auth with google-api-python-client I am creating a gist, because this took me way to long to figure out. Maybe it can save you some time!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib2 | |
from apiclient.discovery import build | |
from oauth2client.client import AccessTokenCredentials | |
def connect_helper(user): | |
c = user.social_auth.get(provider='google-oauth2') | |
access_token = c.tokens['access_token'] | |
credentials = AccessTokenCredentials(access_token, 'my-user-agent/1.0') | |
http = httplib2.Http() | |
http = credentials.authorize(http) | |
service = build(serviceName='calendar', version='v3', http=http, | |
developerKey='...') | |
return service | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment