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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Regular Contributor
Posts: 91
Registered: ‎10-27-2010
My Device: Passport SQW100-1
My Carrier: Meteor

Re: OAuth: Twitter, Facebook & Foursquare Samples!

[ Edited ]

Still doesn't work.

I copied the FB part from app.js to fb.js
I replaced bfb_bootstrap.js complete and changed the BBM ID.

Get this error:

set click handlers fb.js:2
TypeError: 'undefined' is not an object (evaluating 'currentURL.indexOf'): 33

Line 33 in fb.js is:

var inCallback = currentURL.indexOf(callbackURL);


I tried putting the : facebookOptions = in function startOAuth() {

but that doesn't work either


I tried putting in:


var redirectUri = "http://myserver.com/fbouth.php";

and replace with: var inCallback = currentURL.indexOf(redirectUri);


But it wil give the same error, can it be that blackberry deleted indexof ?

I tried with: var inCallback = facebookOptions.redirectUri;


And i disabled: if (inCallback == 0) {  }


Now i get: TypeError: 'undefined' is not an object (evaluating 'code.split')


This means that there are more errors in the script.


Based on code.split and undefined it means that:  var code = childWindow.window.location.search;  does not work either.


I do get the blue page with close button (my app is dark theme so no blue by default)

So i tried to replace childwindow.window to only window.


Than i get:


GET https://graph.facebook.com/oauth/access_token?client_id=201*********&red…m/fbouth.php&client_secret=...




And i get the error: Error getting access_token;



So i tried to go direct to: onclick="startOAuth();"


I added a few extra console.log's to see what is going on, and this is the result.


https://www.facebook.com/dialog/oauth?client_id=20123*****&redirect_ur…ope=email,read_friendlists,us... fb.js:31


local:///check.html fb.js:37


http://myserver.com/fbouth.php fb.js:39




 Small update, when i change: window.location.href; back to childWindow.window.location.href;



I get: TypeError: 'null' is not an object (evaluating 'childWindow.window')


I hope my findings are useful



BlackBerry Development Advisor
Posts: 769
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: OAuth: Twitter, Facebook & Foursquare Samples!



I just used this sample last week without any issues, so I'm mostly confident the sample code works Smiley Happy


As far as I remember, the only thing that might cause the issue when trying to access the childWindow object is if web security is enabeld, you may not be granted access to it.


In your config.xml have you disabled web security?




Also, if you compile and run the sample does it work, or is this error just in your application?


<access uri="*" subdomains="true" />
<preference name="websecurity" value="disable" />


Don't forget to add the plugins as well




New Member
Posts: 1
Registered: ‎12-13-2013
My Device: BlackBerry 10
My Carrier: BlackBerry

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Hello to all!!!!!
A news for blackberry users, that now new action game Angry birds go! download free for iOS, Android, Windows Phone 8, and Blackberry 10 devices....
New Developer
Posts: 4
Registered: ‎03-17-2012
My Device: BlackBerry Z10
My Carrier: Airtel Uganda

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Is it possible to update the Foursquare Sample to Webworks 2.0? 



BlackBerry Development Advisor
Posts: 769
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Actually the best way to authenticate with Foursquare is to use the 'cards' method now.


There's a full sample (WebWorks 2 compatible) at https://github.com/blackberry/BB10-WebWorks-Samples/tree/WebWorks-2.0/Foursquare-Cards

New Member
Posts: 1
Registered: ‎08-13-2014
My Device: z10
My Carrier: Wind

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Hello, thanks a lof for the example.  I just gave this a go;  Though of course the first thing you'll run into is the example uses a redirectUrl of another server ... for many phonegap applications this won't be possible (as of course there is no server).

That is OK there is a solution, that is utilizing a redirectUrl of:

And requesting an access token directly (this is actually safer as well, you should store your app secret in the JS code ... the method used in the example, of requesting a CODE and than an access token is more suitable on a server).

It took a little bit of hacking but I got it working, I'll upload the code somewhere as I'm sure it'll be useful to others. But a question; I noticed no mater what domain I attempted to white list (i.e. https://www.facebook.com/connect) including sub domains it wouldn't work ... the problematic code is generally (from the example, slightly modified):

loginWindow = window.open(FB_LOGIN_URL ...
   window.int = self.setInterval(function() {
        var currentURL = loginWindow.window.location.href; <<<


As you are trying to access a frame from a different domain.

The only solution was to disable web-security all together, after which it finally worked ! I'm just curious, is there any way around this ?

Second question:

The above is all a little pain, most platforms handle the 'loadstart / loadstop / exit' handlers on windows.open, which makes the code a little cleaner and it would work on all phonegap platforms, will this be supported in web works one day ?

Thanks a lot !