Login/Auth & Redirect URI Help

The first issue looks like you are not passing the client_id when authenticating with Twitch. The not found 404 could very well be that it cannot find the redirect, but not entirely sure. I usually use separate pages for redirects when capturing data for authentication, but I admit I use mine more for capturing tokens than using as a login service. However, the overall usage should be the same, if there is an authentication that occurs, Twitch will send the user automatically to the redirect_uri which you can use as your landing page and then redirect them to the protected area of your site.

I am not sure if this would help you, but a JS SDK is provided by Twitch, unless this is what you are trying to use already: