I think you might actually want chat_auth (at least that’s what the quoted Python script is doing)
chat_auth