When you got your RESPONSE did you check of the “error” was “”
An empty error means “ok”, but a non empty error will describe an error if one is present:
No error:
{ type: 'RESPONSE',
error: '',
nonce: 'BCarlyon-asdasdasd-1568630369877' }
Has Error
{ type: 'RESPONSE',
error: 'ERR_BADAUTH',
nonce: 'BCarlyon-adasdasd-1568630369993' }
Given most of your oAuth logic is commented out I’m assuming you have something else handling the oAuth side (step one of an oAuth is redirect the user offsite can’t be done progmatically)
I don’t really see anything else wrong with your code.
The only difference between your code and mine is that I’m using require('ws') rather than require('websocket').w3cwebsocket;
And my oAuth logic is no where near the PubSub handler