Beispiel #1
0
 def get_userinfo(self, google_id, credentials, http=None):
     if http is None:
         http = httplib2.Http()
         credentials.authorize(http)
     service = build_google_client('oauth2', 'v2', http=http)
     userinfo = service.userinfo()
     try:
         return userinfo.get().execute()
     except NotImplementedError:
         # TODO: Catch I/O errors.
         return None
Beispiel #2
0
 def get_profile_and_email(self, google_id, credentials):
     http = httplib2.Http()
     credentials.authorize(http)
     service = build_google_client('plus', 'v1', http=http)
     people = service.people()
     try:
         profile = people.get(userId='me').execute()
         try:
             userinfo = self.get_userinfo(google_id, credentials, http=http)
         except NotImplementedError:
             # TODO: Catch I/O errors.
             return profile
         for key in ('verified_email', 'email'):
             profile[key] = userinfo[key]
         return profile
     except NotImplementedError:
         # TODO: Catch I/O errors.
         return None