0

I am working on an Android application where I login into a banking site . I am able to login successfully with HTTP request and response handling.

But when I enter a wrong username and password in the native android application I am not able to capture that response from HTTP. If I enter a wrong password instead of logging in, it launches a webpage in the webview. But I should override this in my native application.

How can I capture wrong password response from HTTP?

3
  • And even for Wrong username and password I get HTTP OK 200 as response. So not able to differentiate... Commented Nov 5, 2011 at 18:01
  • why don't return response in a string like "Wrong username and password" or something like wrong username/password code like "0" or "1"? Commented Nov 5, 2011 at 18:16
  • A banking site? You're going totally wrong about this. Contact the banking site support and inform for an API. Commented Nov 5, 2011 at 19:12

2 Answers 2

1

It sounds kind of tacky to go about this without a proper API. Anyways, one way of capturing the response has already been mentioned: parse the HTML and figure out based on the content wether login was successfull.

However, depending on the behavior of the bank's website, you might be able to suffice with checking the URL, if for example it redirects you to an error page. From your description it appears you're using a WebView, so you may want take a look at the WebViewClient's shouldOverrideUrlLoading (WebView view, String url) to do a check on the URL that is about to be loaded. An example of using this method can be found here.

Sign up to request clarification or add additional context in comments.

Comments

1

Your problem is that the site you connect to is returning a 200 OK when you supply the incorrect username and password, which is perfectly natural for a web application. You have to parse the HTML result and handle a "Wrong username or password" message as an "Access denied".

2 Comments

Is there anyway I get wrong username password response from cookies?
I think you need to look up on the HTTP protocol a bit. Cookies are typically used to hold information on the user, including a session cookie, which indicates that te user has a session on the server. I have never seen anyone use cookies to indicate that the username and password was incorrect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.