I’m thinking about making an app that gets data from a website. However this website can only be entered after entering a username and password. For example if you go to Example.com the browser would prompt you with something like “A username and password are being requested by example.com” and allow you to enter the username and password. How would I deal with this inside an app? I’m planning to use jsoup to collect the data once I get by the log-in.
Thanks.
I’m thinking about making an app that gets data from a website. However this
Share
It depends a little how the login is implemented. If it is a HTTP POST request you could often do it in JSoup like this:
Connection.Response response = Jsoup.connect(url).data("username", "user", "password", "pwd").method(Method.POST).execute(). “username” and “password” are the names of the POST parameters that often correspond with HTML form fields. This is a working albeit simple approach. Sometimes (often) pages use additional security measures like Captchas or utilize Javascript for e.g. encryption of the password. Then you need to simulate that. But that depends on the specific site implementation.If he site uses Basic HTTP authentication (your description of a popup sounds a little like it) you can find a solution here: Jsoup connection with basic access authentication .