вторник, 11 ноября 2014 г.

How to implement the logout from VK.COM in the standalone app

I'm developing the application for Windows Phone and Windows RT which is a social network VK.COM client. For a long time I have been searching for a way to implement logout from it. It was not trivial task because VK API is not supporting logout. 
While I was searching the solution in the internet I saw two kinds of the solution: 
  1. So-called "direct authorisation" which allows to authorizate in the application with the login and the password. It is avaible only for applications which are aprooved by vk and it requires an "eternal" token. But some developpers disassemble foreign applications and steal eternal tokens.
  2. Deleting the cookies with authorization data.
I have choosed the second one. There is code below which deletes necessary cookies and must be called before logging in of the other user.


Code:
var myFilter = new Windows.Web.Http.FiltersHttpBaseProtocolFilter();
var cookieManager = myFilter.CookieManager;
var myCookieJar = cookieManager.GetCookies(new Uri("https://oauth.vk.com"));
foreach (var cookie in myCookieJar)
{
   cookieManager.DeleteCookie(cookie);
}

Комментариев нет:

Отправить комментарий