0

I have an app that i am writing that requires a user to authenticate through OAuth, and then returns some JSON with a Secret key etc. I am achieving this through a browser Intent, and the information is returning to the browser but not the application. There are multiple stages to the authentication inside the browser, with the user inputting their email and password twice before the JSON is returned.

My question is this - is there anyway to set up a listener for that Intent that returns the data from the Intent when the browser finally loads the JSON response page?

Thanks in advance.

Steve Vincent
  • 199
  • 3
  • 15
  • I think from your question you are getting Json result from the API.Then you can parse that Json and you can proceed.. – Subburaj Dec 09 '13 at 14:46

1 Answers1

0

If you mean by saying "browser" an Android system browser, then answer is no. You should use Webview for this task.


Edit:

OAuth process had to be done like this:

  • Open webview for user to login.
  • Set onPageStarted listener to handle specific url after user login. In that response you can get token.

    webview.setWebViewClient(new WebViewClient() {
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            //get token here. Most often token is added to url
    });
    
  • After you have token, make separate request with HttpURLConnection or any other connection.

If you actually must do everything in WebView and want to get page content look at this thread

Community
  • 1
  • 1
user123
  • 1,053
  • 15
  • 27
  • Ok thanks, i've changed over to the webview, enabled JavaScript and gone through the two authentication processes, and now inside my webview i have the data in JSON format that i want to take - any ideas how i would go about grabbing that? Again, thanks for the help. – Steve Vincent Dec 10 '13 at 15:56
  • Thank you, i got this working in the end due to your comment, much appreciated! – Steve Vincent Dec 15 '13 at 15:51
  • No problem. In this community (Stackoverflow) accepting and voting up answer is good way showing your appreciation :P – user123 Dec 15 '13 at 19:32
  • i cannot vote you up as i dont have the reputation but i have marked this answer as correct. thank you again! – Steve Vincent Dec 15 '13 at 21:15