I understand: the question is not new, I found several very similar implementations, but not one of them does not work for me ((.. The first problem arises here:
HttpClient client=HttpClientBuilder.create().build(); StringBuilder request =new StringBuilder(); request.append("https://oauth.vk.com/authorize?client_id=").append(APP_ID). append("&display=page&redirect_uri=").append(REDIR_URI).append("&scope="). append(SCOPE).append("&response_type=token&v=5.45"); HttpGet get=new HttpGet(request.toString()); HttpResponse resp=client.execute(get); System.out.println(resp.getFirstHeader("Location").getValue());
firstly there is no such title, and secondly a warning is transmitted:
ber. 07, 2016 9:13:13 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Invalid cookie header: "Set-Cookie: remixlang = 1; expires = Fri, 03 Mar 2017 14:08:26 GMT; path = /; domain = .vk.com ". Invalid 'expires' attribute: Fri, 03 Mar 2017 14:08:26 GMT
ber. 07, 2016 9:13:13 PM org. path = /; domain = .vk.com ". Invalid 'expires' attribute: Thu, 16 Mar 2017 11:05:21 GMT
The server returns the code 200
From the server, I get these Headers:
Server: Apache Date: Mon, 07 Mar 2016 21:28:09 GMT Content-Type: text / html; charset = utf-8 Connection: keep-alive X-Powered-By: PHP / 3.21901 Set-Cookie: remixlang = 1; expires = Sat, 04 Mar 2017 18:01:50 GMT; path = /; domain = .vk.com Set-Cookie: remixlhk = 0e65abac9fd62d58fc; expires = Tue, 28 Feb 2017 17:46:12 GMT; path = /; domain = .vk.com Pragma: no-cache Cache-control: no-store
X-Frame-Options: SAMEORIGIN
Already hands are falling .. Tell me how is the authorization done (vkontakte or any other site with a form)? Because I’m trying to get a "location" header on another site - it’s not in the answer. Tell me the algorithm or where and what to read for the practical part?