The first step of oAuth is to redirect the User from your website to Twitch’s, you seem to be trying to fetch the webpage instead of redirecting the user to Twitch
An example using implicit oAuth
The login link will take the user to Twitch.
The user will accept/deny the app
They will come back to your with an access token.
Usually they’ll come back with a code and you exchange the code for a token/refresh token, but this demo is the implicit method that returns only a token