def load_config_key():
global api_token<EOL>try:<EOL><INDENT>api_token = os.environ['<STR_LIT>']<EOL><DEDENT>except KeyError:<EOL><INDENT>home = os.path.expanduser("<STR_LIT>")<EOL>config = os.path.join(home, "<STR_LIT>")<EOL>if not os.path.exists(config):<EOL><INDENT>with open(config, "<STR_LIT:w>") as cfile:<EOL><INDENT>key = get_input_key()<EOL>cfile.write(key)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with open(config, "<STR_LIT:r>") as cfile:<EOL><INDENT>key = cfile.read()<EOL><DEDENT><DEDENT>if key:<EOL><INDENT>api_token = key<EOL><DEDENT>else:<EOL><INDENT>os.remove(config)  <EOL>click.secho('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>.format(RequestHandler.BASE_URL), fg="<STR_LIT>", bold=True)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>return api_token<EOL>
Load API key from config file, write if needed