def is_token_expired(token, auth_details):
    for fmt in ('%Y-%m-%dT%H:%M:%SZ', '%Y-%m-%dT%H:%M:%S.%fZ'):
        try:
            if auth_details['OS_AUTH_URL'].endswith('v3'):
                expires_at = token.get('expires_at')
            else:
                expires_at = token['token'].get('expires')

            expires = datetime.datetime.strptime(expires_at, fmt)
            break
        except __HOLE__ as e:
            pass
    else:
        raise e
    return datetime.datetime.now() >= expires
dataset/ETHPy150Open rcbops/rpc-openstack/maas/plugins/maas_common.py/is_token_expired