He became a public socialist when he sought the endorsement of the New Party in 1995.
The New Party required candidates who received the endorsement sign a pledge of support for the party. Obama signed that pledge, choosing to support a party that was, in effect, a front group for communists.