06-22-2009 02:05 AM
I am facing a problem..I am unable to connect any site which asks for authentication through browser field...
I have tried
It connects fine when using BB Native browser...am I missing some thing ? Should there be some HTTP Authentication support that I have to set ? os should I have to add some additional request headers ?
How can this be achived using browser field in my application ?
06-29-2009 11:48 AM
Note that the browser field samples included with the BlackBerry JDE have not implemented support for cookies, which would be required for most sites that require authentication. Please refer to the following.
How To – Enable cookies in BrowserField
Article Number: DB-00675
05-31-2011 12:34 PM
Actually, I found a little issue in the "Enable Cookies in the BrowserField" example.
As you know, you are getting the Field content using getHeaderField(String key).
Well. Using the Browserfield for a very simple Facebook HTTP login enabler, I receive the following headers for OAuth process:
HTTP/1.0 302 Found
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Type: application/xhtml+xml; charset=utf-8
Expires: Sat, 01 Jan 2000 00:00:00 GMT
P3P: CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p"
Set-Cookie: datr=PxXlTZUuW8o5Z4K69O3KaksD; expires=Thu, 30-May-2013 16:20:15 GMT; path=/; domain=.facebook.com; httponly
Set-Cookie: lsd=n9lMs; path=/; domain=.facebook.com
As you can see, there are two Set-Cookie keys in the headers. So, using the getHeaderField(String key). method, I'll get only the first key-ocurrence value, that is, I'll never handle the other cookie values.
The solution is obvlous, just replacing getHeaderField(String key) for getHeaderField(int index), as follows:
for (int i = 0;(key = connection.getHeaderFieldKey(i)) != null; i++)
String cookieContent=connection.getHeaderField(i); //Instead connection.getHeaderField(key)
Hope this can help some programmers!