def authorize(self, api_token=None, username=None, password=None):
        """
        Authorize a user using the browser and a CherryPy server, and write
        the resulting credentials to a config file.
        """

        access_token = None

        if username and password:
            # if we have a username and password, go and collect a token
            auth = ExistAuthBasic(username, password)
            auth.authorize()
            if auth.token:
                access_token = auth.token['access_token']
        elif api_token:
            # if we already have a token, just use that
            access_token = api_token
        else:
            # if we have a client_id and client_secret, we need to
            # authorize through the browser
            auth = ExistAuth(self.client_id, self.client_secret, 'code', self.redirect_uri)
            auth.browser_authorize()
            if auth.token:
                access_token = auth.token['access_token']

        # store the access token in the config file
        if access_token:
            self.write_config(access_token)
        else:
            print('ERROR: We were unable to authorize to use the Exist API.')
Authorize a user using the browser and a CherryPy server, and write
        the resulting credentials to a config file.