def json_set_auths(recipe, auth):
  """Recusrsively finds auth in script JSON and sets them.

    Args:
      recipe: (dict) A dictionary representation fo the JSON script.
      auth: (string) Either 'service' or 'user'.

    Returns:
      (recipe) same structure but with all auth fields replaced.

  """

  if isinstance(recipe, dict):
    if 'auth' in recipe:
      recipe['auth'] = auth
    for key, value in recipe.items():
      json_set_auths(value, auth)
  elif isinstance(recipe, list) or isinstance(recipe, tuple):
    for index, value in enumerate(recipe):
      json_set_auths(value, auth)

  return recipe