Question

I am trying to implement authentication of my standalone java application at VKontakte - Russian social network.

I want to avoid requesting a password from the user, so my method is like this:

  1. open default browser with a special generated URL
  2. in the opened page user clicks Accept button
  3. browser gets redirected to a special URL from where I can extract access_token which is supposed to be used for any other further request.

But the problem is that I do not know how to get that new URL from the browser. The code I am using is

if (Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.BROWSE)) {
            try {
                URI uri = new URI("some URL here");
                desktop.browse(uri);
Was it helpful?

Solution

You can't do that with Desktop.browse(). You are initializing an instance of a program(browser) that java has no access to. Java only passed the URL you provided.

(Theoretically it would be possible, if i.e. Desktop.browse() would start a custom made Browser that you can communicate with via Java API)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top