Frage: Zugriff auf passwortgeschützten Webbereich

  • 3 Antworten
  • Letztes Antwortdatum
M

movinganimations

Neues Mitglied
0
Hey Leute, ich hab eine Frage an euch, ich möchte mit meiner App mit manueller Passwort Eingabe auf einen geschützten Bereich zugreifen, also das Passwort und Benutzername mit senden. Leider kommt immer als Ergebnis das im WebView Fenster

Authorization Required

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.

Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.26 with Suhosin-Patch mod_ssl/2.2.8 OpenSSL/0.9.8g Server

ich hoffe ihr könnt mir helfen

Daaanke im vorraus
 
Wie versuchst du denn, die Credentials zu übergeben? Die einfachste Methode ist es, alles in die URL
Code:
https://user:passwort@host/mein_dokument.html
zu packen. Ist nicht in jeder Umgebung so ratsam, aber zum Testen ganz praktisch.
 
so hab ichs gedacht, aber die lösung von dir werde ich gleich mal implementieren

Code:
final String httpsURL = "https://the url"; final DefaultHttpClient client = new DefaultHttpClient(); final HttpPost httppost = new HttpPost(httpsURL);  //authentication block: final List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>(); nvps.add(new BasicNameValuePair("userName", userName)); nvps.add(new BasicNameValuePair("password", password)); final UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(nvps, HTTP.UTF_8); httppost.setEntity(p_entity);  //sending the request and retrieving the response: HttpResponse response = client.execute(httppost); HttpEntity responseEntity = response.getEntity();  //handling the response: responseEntity.getContent() is your InputStream final InputSource inputSource = new InputSource(responseEntity.getContent());


Der ursprüngliche Beitrag von 10:47 Uhr wurde um 11:01 Uhr ergänzt:

also so?
Code:
webview.loadUrl("https://user:pw@host/datei.htm");
 
Was du in deinem Vorschlag übergibts, sind zwei Http POST Parameter. Das hat mit Authentisierung erstmal nix zu tun (es gibt Container, die Authentisierung über POST Parameter machen, aber das ist nicht Standard). Du musst in deinem HttpClient Credentials setzen. Google nach "android httpclient credentials"

ad Add: im Prinzip ja, Aber wie gesagt, das ist eher nur etwas zum Testen.
 

Ähnliche Themen

D
Antworten
8
Aufrufe
807
jogimuc
J
Zurück
Oben Unten