'Returns the course for the given course_key_string after
verifying the requested access to the course by the given user.'

def _get_course(self, course_key_string, user, access_action):

    try:
        course_key = CourseKey.from_string(course_key_string)
    except InvalidKeyError:
        return self.make_error_response(status_code=status.HTTP_404_NOT_FOUND, developer_message='The    provided    course    key    cannot    be    parsed.', error_code='invalid_course_key')
    try:
        return courses.get_course_with_access(user, access_action, course_key, check_if_enrolled=True)
    except Http404:
        log.info('Course    with    ID    "%s"    not    found', course_key_string)
    except CourseAccessRedirect:
        log.info('User    %s    does    not    have    access    to    course    with    ID    "%s"', user.username, course_key_string)
    return self.make_error_response(status_code=status.HTTP_404_NOT_FOUND, developer_message='The    user,    the    course    or    both    do    not    exist.', error_code='user_or_course_does_not_exist')
