I have an error while trying to connect to the api with my unity app

This should be

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://id.twitch.tv/oauth2/token?client_id=" + clientId + "&client_secret=" + clientSecret + "&grant_type=client_credentials");

The client_id parameter is all lower case and a _ instead of a -