I am doing it like this and it is working for me as I am getting code
url param when redirected:
openFBLogin : function() {
var my_client_id = Properties.FB_APP_ID,
my_redirect_uri = "http://www.myweb.com?fb_redirect=tabapp",
my_display = "touch";
var authorize_url = "https://graph.facebook.com/oauth/authorize?";
authorize_url += "client_id="+my_client_id;
authorize_url += "&redirect_uri="+my_redirect_uri;
authorize_url += "&display="+my_display;
authorize_url += "&scope=publish_actions%2Cuser_birthday%2Cuser_interests%2Cuser_likes%2Cuser_location%2Cuser_relationships%2Cemail%2Cuser_checkins%2Cuser_hometown%2Cpublish_stream";
Helper.iabRef = window.open(authorize_url, '_blank', 'presentationstyle=formsheet');
Helper.iabRef.addEventListener('loadstop', Helper.iabFBLoginLoadStop);
Helper.iabRef.addEventListener('loadstart', Helper.iabFBLoginLoadStart);
console.log(Helper.iabRef);
},
iabFBLoginLoadStart : function(event){
Helper.onUrlChange(event.url);
},
iabFBLoginLoadStop : function(event){
Helper.onUrlChange(event.url);
},
/**
* Given the FB redirection URL it will check it for success/failure
* If success it will do login else dump error message before closing the browser window
* @param {} url
*/
onUrlChange : function(url){
var error = null;
if(url.indexOf("http://www.myweb.com") == 0){
// User is redirected that means FB job is done
if(/code=/.test(url)){
// If Code param is available that means authentication done
var fbCode = url.match(/code=(.*)$/)[1];
console.log("logged in with fbCode = "+fbCode);
// TODO call login service with this code and
// on success save user credentials returned by service
} else if(/error_description=/.test(url)) {
// if error_description param is present that means login unsuccessful
error = (url.match(/error_description=(.*)$/)[1]).replace(/[^A-Za-z0-9 ]/g, " ");
console.log("Error message : "+error);
}
if(Helper.iabRef){
Helper.iabRef.close();
}
}
if(error){
Ext.Msg.alert('Error','Unable to login using facebook : '+error);
} else{
Ext.Msg.alert('Success','Thanks for logging in');
}
},