Twitter Authentication problem when try to search people on twitter from my application


Hello everyone.
I using the following code to find people on twitter. but it gives me authentication problem (i-e) System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse();

my code goes here:

HttpWebRequest client = (HttpWebRequest)WebRequest.Create(“”);
var ccache = new CredentialCache();
Uri uri = new Uri(“”);
ccache.Add(uri, “Basic”, new NetworkCredential(username, password);
client.Credentials = ccache;
client.Timeout = 20000;
client.PreAuthenticate = true;

        using (HttpWebResponse httpResponse = (HttpWebResponse)client.GetResponse())
            using (Stream stream = httpResponse.GetResponseStream())
                using (StreamReader reader = new StreamReader(stream))
                    return reader.ReadToEnd();


Can anybody tell me how to handle this problem. or any other way to get peoples profiles form the twitter.


You’re attempting to use Basic authorization, which is not supported by the Twitter API.

You’ll need to use OAuth. The following document explains some of the differences between the two protocols, and gives pointers on migrating:

The easiest way to access the API would be to use a client library. We have several .NET libraries listed here:


Also, please change your password as soon as possible


non esiste una versione in italiano