A
A
artshelom2017-08-04 23:59:47
Java
artshelom, 2017-08-04 23:59:47

Is it possible to do automatic authorization?

How to make authorization in VK, Facebook or Instagram?
Authorization data is stored in cookies on the user and on the server. Is it possible to send a get or post request like this after logging in through chrome after receiving cookies

public String getHTML(String urlToRead) {
      URL url;
      HttpURLConnection conn;
      BufferedReader rd;
      String line;
      String result = "";
      try {
         url = new URL(urlToRead);
         conn = (HttpURLConnection) url.openConnection();
         conn.setRequestMethod("GET");
         rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
         while ((line = rd.readLine()) != null) {
            result += line;
         }
         rd.close();
      } catch (Exception e) {
         e.printStackTrace();
      }
      return result;
   }
 
   public static void main(String args[])
   {
     c c = new c();
     System.out.println(c.getHTML(args[0]));
   }

And return certain data?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zakharov Alexander, 2017-08-05
@artshelom

If you are for tests, then I advise you to use fiddler. There is the possibility of scripting and you can replace all sorts of headers and cookies on the fly. Those. you go through authorization on the site (by any method, even post-authentication, even oauth, even openid), pull out cookies or necessary headers from any request after authorization (very rarely), and then replace the parameters in all requests with the fiddler script. This is how I ran tests for SMS authentication, when the program certainly cannot log in itself. In this way, you can make any requests authorized, even curl, wget and others, the main thing is to redirect the request through fiddler. Sometimes a cookie can go rotten, then you re-login, write a new cookie to the fiddler script and continue on ... Armor-piercing crap, even for site-scrabbing. )))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question