import json
def load_auth_tokens(config_file):
"""
Loads authentication tokens from a JSON configuration file.
Args:
config_file (str): Path to the JSON configuration file.
Returns:
dict: A dictionary containing authentication tokens. Returns an empty dictionary if the file is not found or invalid.
"""
try:
with open(config_file, 'r') as f:
config = json.load(f)
return config
except FileNotFoundError:
print(f"Error: Configuration file not found: {config_file}")
return {}
except json.JSONDecodeError:
print(f"Error: Invalid JSON format in {config_file}")
return {}
if __name__ == '__main__':
#Example usage
tokens = load_auth_tokens('auth_config.json') # Replace with your config file
print(tokens)
Add your comment