I am writing a mobile client vk.com using implicit flow. To authorize and receive a token, you need to follow the link, enter the username and password on the site and click ok (using WebView) After that, the user is redirected to another page. In the address of that page there is just a token that I need. How can I get it?

    1 answer 1

    Apparently you need to intercept transitions in WebView through WebViewClient .

     WebViewClient webViewClient = new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.d(TAG, "overrideUrlLoading with URL: " + url); if (url.contains("token=")) { //например токен у вас в адресе начинается после "token=" //значит надо помешать переходу на этот адрес, вернув true return true; } return false; } }; webView.setWebViewClient(webViewClient); 
    • I'll try, thank you :) - Alexander Borisov
    • one
      Works! Thanks again :) Zaapruvil your answer :) - Alexander Borisov