def GetAnalyticsClient():
 SOURCE_APP_NAME = 'Analytics-ManagementAPI-Demo-v1'
 my_client = gdata.analytics.client.AnalyticsClient(source=SOURCE_APP_NAME)
 try:
  gdata.sample_util.authorize_client(my_client, service=my_client.auth_service, source=SOURCE_APP_NAME, scopes=['https://www.google.com/analytics/feeds/'])
 except gdata.client.BadAuthentication:
  exit('Invalid user credentials given.')
 except gdata.client.Error:
  exit('Login Error')
 return my_client

def GetAnalyticsClient ( ) : SOURCE_APP_NAME = 'Analytics-ManagementAPI-Demo-v1' my_client = gdata . analytics . client . AnalyticsClient ( source = SOURCE_APP_NAME ) try : gdata . sample_util . authorize_client ( my_client , service = my_client . auth_service , source = SOURCE_APP_NAME , scopes = [ 'https://www.google.com/analytics/feeds/' ] ) except gdata . client . BadAuthentication : exit ( 'Invalid user credentials given.' ) except gdata . client . Error : exit ( 'Login Error' ) return my_client
returns an authorized googleanalayticsclient object .