Friday, 4 March 2011
















  if self.auth_token:
    return self.auth_token


  self.auth_token =
    self.auth_routine_util.LoadAuthToken(self.token_obj_name)


  if not self.auth_token:
    self.auth_token = self.RequestAuthToken()


  self.auth_routine_util.SaveAuthToken(self.auth_token)
  return self.auth_token









  url = ('%s?xoauth_displayname=%s' %
      (gdata.gauth.REQUEST_TOKEN_URL, self.my_client.source))


  request_token = self.my_client.GetOAuthToken(

      next='oob',
      consumer_key='anonymous',
      consumer_secret='anonymous',
      url=url)


  verify_url = request_token.generate_authorization_url(
      google_apps_domain='default')


  print 'Please log in and/or grant access at: %s\n' % verify_url
  webbrowser.open(str(verify_url))


  request_token.verifier =
'Please enter the verification code '
                'on the success page: ')


  try:
    return self.my_client.GetAccessToken(request_token)


  except gdata.client.RequestError, err:
    raise AuthError(msg='Error upgrading token: %s' % err)






  my_client.auth_token = my_auth.GetAuthToken()


except auth.AuthError, error:
  print error.msg
  sys.exit(1)




  feed = my_client.GetDataFeed(data_query)


except gdata.client.Unauthorized, error:
  print '%s\nDeleting token file.' % error
  my_auth.DeleteTokenFile()
  sys.exit(1)







Tagged: