Chat doesn’t need a token to connect to
This program seems to look up users in the API (probably to get profile pictures). So the problem in this program is not the chat connection but the API usage.
So yes, chat technically doesn’t need a token but the other things this program does will need a token.