The reason you’re getting a 404 is because you’re POST’ing to the wrong URL. https://api.twitch.tv/kraken/oauth2/token should be https://api.twitch.tv/api/oauth2/token
POST https://api.twitch.tv/api/oauth2/token
?client_id=<your client ID>
&client_secret=<your client secret>
&code=<authorization code received above>
&grant_type=authorization_code
&redirect_uri=<your registered redirect URI>