'Login to the repository, in Wrike: use the client ID (username),
the client secret (password) and the refresh token to obtain the
access token for subsequent requests.
@return: None if successful, otherwise error message'

def login(self):

    repository = self.repository
    log = repository.log
    error = None
    remote = False
    refresh_token = repository.refresh_token
    if (not refresh_token):
        result = log.FATAL
        error = 'Login    failed:    no    refresh    token    available    (registration    failed?)'
    else:
        data = {'client_id': repository.client_id, 'client_secret': repository.client_secret, 'grant_type': 'refresh_token', 'refresh_token': refresh_token}
        (response, message) = self._send_request(method='POST', data=data, auth=True)
        if (not response):
            result = log.FATAL
            remote = True
            error = message
        else:
            access_token = response.get('access_token')
            if (not access_token):
                result = log.FATAL
                error = 'No    access    token    received'
            else:
                result = log.SUCCESS
                self.access_token = access_token
                self.token_type = response.get('token_type', 'bearer')
    log.write(repository_id=repository.id, transmission=log.OUT, mode=log.PUSH, action='request    access    token', remote=remote, result=result, message=error)
    if error:
        current.log.error(error)
    return error
