Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Afzal
Posts: 31
Registered: ‎06-12-2009
My Device: Not Specified

HTTP Authentication in browser field

Hi,

 

I am facing a problem..I am unable to connect any site which asks for authentication through browser field...

 

I have tried

 

facebook

twitter

yahoo

 

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 ?

 

Thank you.

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: HTTP Authentication in browser field

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

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800440/How_To_...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Contributor
aitriago
Posts: 6
Registered: ‎02-26-2010
My Device: 8900 4.6.1
My Carrier: Digitel

Re: HTTP Authentication in browser field

Hi Mark.

 

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                                                                          
Location: http://m.facebook.com/connect/uiserver.php?app_id=XXXXX&method=permissions.request&display=wa
p&next=URL&resp
onse_type=code&fbconnect=1&perms=publish_stream                                                                 
P3P: CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p"                                 
Pragma: no-cache                                                                                                
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                                                             
X-FB-Server: 10.54.41.43                                                                                        
Connection: close                                                                                               
Content-Length: 0 

 

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++)
            {
                if (key.equalsIgnoreCase("set-cookie"))
                {
                    String cookieContent=connection.getHeaderField(i); //Instead connection.getHeaderField(key)


                 }

           }

----

 

Hope this can help some programmers!

Regards.-

 

 

Anibal Itriago

 

 

 

 

Please use plain text.