from typing import Dict
from pathlib import Path
import json


def get_credentials() -> Dict[str, str]:
	""" Retrieves the client ID and client secret that have been saved previously."""
	beagle_path = Path("/home/data/boxapi.txt")
	if beagle_path.exists():
		contents = [i.strip() for i in beagle_path.read_text().split("\n") if i]
		key, secret, folder_id = contents
		data = {
			"boxAppSettings": {
				"clientID":     key,
				"clientSecret": secret
			}
		}
		global PARENT_FOLDER_ID
		PARENT_FOLDER_ID = folder_id
	else:
		filename = Path.home() / "box_credentials.json"
		data = json.loads(filename.read_text())

	return data['boxAppSettings']