Как авторизоваться на сайте вконтакте? C#
Добавлено: 23 окт 2015, 20:03
Здравствуйте.
Как авторизоваться в контакте для использования API?
Такой код выдает мне ошибку 401 :
Вот такая ошибка происходит в последней строке кода:
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: Удаленный сервер возвратил ошибку: (401) Несанкционированный.
Как авторизоваться в контакте для использования API?
Такой код выдает мне ошибку 401 :
Код: Выделить всё
string URI = @"https://oauth.vk.com/token"; string Parameters = "grant_type=password&client_id=****&client_secret=****&username=****&password=****"; WebRequest req = WebRequest.Create(URI); req.Method = "POST"; byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters); req.ContentLength = bytes.Length; System.IO.Stream strm = req.GetRequestStream(); strm.Write(bytes, 0, bytes.Length); strm.Close(); System.Net.WebResponse resp = req.GetResponse();
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: Удаленный сервер возвратил ошибку: (401) Несанкционированный.