Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Access a site that uses basic auth using a WebView


Is there any way to point a web view at a site that uses basic auth and handle either setting the credentials in the header or programatically responding to the authentication challenge?

Ideally I'd like the user to enter their credentials in app settings and then handle the auth for the user when I point the Webview at the site on subsequent uses of the app.

With the Native version of this app I created my own NSURLConnection and NSURLRequest objects and handled the didReceiveAuthenticationChallenge() callback, then I took that Request object and handed it to the WebView like this:

[webView loadRequest:_request];

That way the WebView was using the same session where I had already handled the auth under the hood. Make sense?

So, is there any analog for this when using Titanium's WebView? Any creative workaround ideas?


Make sense?

— asked March 30th 2010 by Shaun Sullivan

2 Answers

  • Accepted Answer

    you can use http://username:password@secure.site.com for your http request.

    — answered March 30th 2010 by Kosso
  • jQuery's low level interface for asynchronous requests allows you to pass on a username and password for HTTP authentication:

        // ...
        username : 'foo',
        password : 'bar'

    —Any use for you in this case?

    — answered March 30th 2010 by Florian Plank
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.