adding support to loading API token from an environment variable to remove secrets from config file

This commit is contained in:
Samantha Marshall
2016-12-28 08:49:25 -05:00
parent c50877bb58
commit 0919339caf

View File

@@ -33,7 +33,11 @@ class Config:
try:
return self.config.get('user', 'token')
except (configparser.NoOptionError, configparser.NoSectionError):
raise ConfigError('no API token found in config file')
environment_variable_fallback = self.env.get('ASCIINEMA_TOKEN')
if environment_variable_fallback is not None:
return environment_variable_fallback
else:
raise ConfigError('no API token found in config file, and ASCIINEMA_TOKEN is unset')
@property
def record_command(self):