The TwitterAPI constructor expects an object with an "accessSecret" key (among others) as parameter.
The Github Copilot suggested "accessTokenSecret" instead. Even though the suggested value was correct, it seems that having the wrong key name means the secret is not sent, which causes the 401.