code: def GetCredentials(package_name, scopes, client_id, client_secret, user_agent,
                     credentials_filename=None,
                     api_key=None,
                     client=None,
                     oauth2client_args=None,
                     **kwds):
      scopes = util.NormalizeScopes(scopes)
      client_info = {
          'client_id': client_id,
          'client_secret': client_secret,
          'scope': ' '.join(sorted(scopes)),
          'user_agent': user_agent or '%s-generated/0.1' % package_name,
      }
      for method in _CREDENTIALS_METHODS:
          credentials = method(client_info, **kwds)
          if credentials is not None:
              return credentials
      credentials_filename = credentials_filename or os.path.expanduser(
          '~/.apitools.token')
      credentials = CredentialsFromFile(credentials_filename, client_info,
                                        oauth2client_args=oauth2client_args)
      if credentials is not None:
          return credentials
      raise exceptions.CredentialsError('Could not create valid credentials')