P
P
Pidgeot2022-02-14 21:31:06
Java
Pidgeot, 2022-02-14 21:31:06

Is it possible to pass authorization with getting code through Java SDK?

Good afternoon!
I wanted to try the VK API through the JAVA SDK. According to the VK manuals, I first tried to get the code and token in the browser - everything worked out. But I wanted to make some kind of my own client application, for now without specific goals, it is possible to keep statistics of which of my friends is online for how long, etc. just for study. And then immediately the problem: I can not pass authorization without specifying the token. Although the essence is just that the token is formed as a result of the request

https://oauth.vk.com/authorize?client_id=1&display=page&redirect_uri=http://example.com/callback&scope=friends&response_type=code&v=5.131
- VK example. Using such a not tricky code, I get a message that I am not authorized, therefore no code is generated.
kusman code inside
URL redir_url = new URL(OAUTH_URI);
        HttpURLConnection con = (HttpURLConnection) redir_url.openConnection();
        int responsecode = con.getResponseCode();
        String answer = con.getResponseMessage(); 
        System.out.println("resp: " + responsecode + " answer: " + answer);

in OAUTH_URI, respectively, lies the example that I wrote above, from the VK docks.
If this URI is replaced, for example, with https://oauth.vk.com/blank.html, then in the console we get a response and information about this page without any problems.
Accordingly, something is completely unclear to me, whether it is possible to programmatically pass authorization from the code, perhaps with the login and password of the page or in another way, but in order to eventually form a request that will give a code or token, or this option is not possible in principle and you need to constantly generate it with your hands, then insert it into the code and then run to collect information and do what you want? Thank you all for your reply

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question