Don't save empty keys to the config file
@@ -113,10 +113,18 @@ def configure(ctx):
config = configobj.ConfigObj(unrepr=True)
config.filename = config_file
- config['consumer_key'] = keys['consumer_key']
- config['consumer_secret'] = keys['consumer_secret']
- config['access_token'] = keys['access_token']
- config['access_token_secret'] = keys['access_token_secret']
+
+ # Only write non empty keys.
+ for key in [
+ "consumer_key",
+ "consumer_secret",
+ "access_token",
+ "access_token_secret",
+ "bearer_token"
+ ]:
+ if keys.get(key, None):
+ config[key] = keys[key]
+
config.write()
click.echo(click.style(f'\nYour keys have been written to {config_file}', fg='green'))
