<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_client_token():
 """ Requests and stores the NOMIS API client token from mtp-api """

    if getattr(settings, 'NOMIS_API_CLIENT_TOKEN', ''):
        return settings.NOMIS_API_CLIENT_TOKEN
    global client_token
    if not client_token or client_token['expires'] and client_token['expires'] - now() < datetime.timedelta(days=1):
        session = None
        try:
            session = api_client.get_authenticated_api_session(settings.TOKEN_RETRIEVAL_USERNAME,
                                                               settings.TOKEN_RETRIEVAL_PASSWORD)
            client_token = session.get('/tokens/nomis/').json()
        except (requests.RequestException, HttpNotFoundError, ValueError, AttributeError):
            logger.exception('Cannot load NOMIS API client token')
            return None
        finally:
            if session and getattr(session, 'access_token', None):
                api_client.revoke_token(session.access_token)
        if client_token.get('expires'):
            client_token['expires'] = parse_datetime(client_token['expires'])
            if client_token['expires'] < now():
                logger.error('NOMIS API client token from mtp-api had expired')
                return None
    return client_token['token']