code: def authorized_http(client_id, client_secret, apps, file=None):
      
      if not os.path.exists(CREDENTIAL_DIR):
          os.makedirs(CREDENTIAL_DIR)
  
      credential_path = file or CREDENTIAL_PATH
      storage = Storage(credential_path)
      credentials = storage.get()
  
      scopes = set([
          "https://www.googleapis.com/auth/{0}.readonly".format(app)
          for app in apps
          ])
  
      if (not credentials or credentials.invalid
              or not scopes <= credentials.scopes):
          flow = OAuth2WebServerFlow(
              client_id=client_id,
              client_secret=client_secret,
              scope=scopes,
              redirect_uri=REDIRECT_URI)
          flow.user_agent = USER_AGENT
  
          # Do not parse did command-line options by OAuth client
          flags = tools.argparser.parse_args(args=[])
          credentials = tools.run_flow(flow, storage, flags)
  
      return credentials.authorize(httplib2.Http())
docs: Start an authorized HTTP session.
  
      Try fetching valid user credentials from storage. If nothing has been
      stored, or if the stored credentials are invalid, complete the OAuth2 flow
      to obtain new credentials.