Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
use 'oauth2' google service instead of 'plus' service
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyclark authored and eriktaubeneck committed Dec 12, 2013
1 parent 87ac707 commit 714eab9
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions flask_social/providers/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,24 @@
},
'request_token_params': {
'response_type': 'code',
'scope': 'https://www.googleapis.com/auth/plus.me'
'scope': 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me'
#add ' https://www.googleapis.com/auth/userinfo.email' to scope to also get email
}
}

def _get_api(credentials):
http = httplib2.Http()
http = credentials.authorize(http)
api = googleapi.build('oauth2', 'v2', http=http)
return api


def get_api(connection, **kwargs):
credentials = googleoauth.AccessTokenCredentials(
access_token=getattr(connection, 'access_token'),
user_agent=''
)

http = httplib2.Http()
http = credentials.authorize(http)
return googleapi.build('plus', 'v1', http=http)
return _get_api(credentials)


def get_provider_user_id(response, **kwargs):
Expand All @@ -52,11 +56,7 @@ def get_provider_user_id(response, **kwargs):
access_token=response['access_token'],
user_agent=''
)

http = httplib2.Http()
http = credentials.authorize(http)
api = googleapi.build('plus', 'v1', http=http)
profile = api.people().get(userId='me').execute()
profile = _get_api(credentials).userinfo().get().execute()
return profile['id']
return None

Expand All @@ -72,11 +72,7 @@ def get_connection_values(response, **kwargs):
user_agent=''
)

http = httplib2.Http()
http = credentials.authorize(http)
api = googleapi.build('plus', 'v1', http=http)
profile = api.people().get(userId='me').execute()

profile = _get_api(credentials).userinfo().get().execute()
return dict(
provider_id=config['id'],
provider_user_id=profile['id'],
Expand Down

0 comments on commit 714eab9

Please sign in to comment.