Authorize device synchronization.

def auth(**kwargs):
  ''' Authorize device synchronization. '''

  """
    kodrive auth <path> <device_id (client)>

    1. make sure path has been added to config.xml, server
    2. make sure path is not shared by someone
    3. add device_id to folder in config.xml, server
    4. add device to devices in config.xml, server

  """

  option = 'add'
  path = kwargs['path'] 
  key = kwargs['key']

  if kwargs['remove']:
    option = 'remove'

  if kwargs['yes']:
    output, err = cli_syncthing_adapter.auth(option, key, path)
    click.echo("%s" % output, err=err)
  else:
    verb = 'authorize' if not kwargs['remove'] else 'de-authorize'
    if click.confirm("Are you sure you want to %s this device to access %s?" % (verb, path)):
      output, err = cli_syncthing_adapter.auth(option, key, path)

      if output:
        click.echo("%s" % output, err=err)