Created
August 7, 2013 22:39
-
-
Save rchrd2/6179550 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 | |
This will not automatically refresh an offline token right?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're a godsend!