From the 29th May 2017 all calls will require an access token on Spotify. I had developed a web C# application which could get music track information successfully.
Uri uri = new Uri(@"https://api.spotify.com/v1/search?q=" + txtartist.Text + "%20" + txttrack.Text + "&type=track");
WebRequest webRequest = WebRequest.Create(uri);
WebResponse response = webRequest.GetResponse();
StreamReader streamReader = new StreamReader(response.GetResponseStream());
But after the recent change, it encounters the error 401 (unauthorized access). How can I add a code to the above code so that the authentication can be done before getting the information?
I think it is possible to create a webrequest object from only one URI, while two URIs is needed (one for authentication and another for search) and I need one integrated code.
P.S.: According to the reference one solution would be:
curl -X GET "https://api.spotify.com/v1/search?q=tania%20bowra&type=artist" -H "Authorization: Bearer {your access token}"
but I do not know how to use the first text after GET (between the quotations) and the second text after -H in the same time for a webrequest object.
Thanks in advance.