So I’m trying to get an access token from facebook to use with my firefox plugin, so from facebooks point of view I’m a desktop application.
My biggest problem is to detect the redirect to …/login_success.html as I don’t know how to do that without crashing firefox.
That’s my latest try:
function getAuthToken() {
var app_id = 'MY ID';
var redirect_uri = 'https://www.facebook.com/connect/login_success.html';
var permissions = ['user_photos', 'friends_photos',
'publish_stream', 'offline_access'];
var url = 'https://www.facebook.com/dialog/oauth?' +
'client_id=' + app_id + '&redirect_uri=' + redirect_uri +
'&scope=' + permissions.join(',') + '&response_type=token';
window.open(url);
while(true){
if(window.onload)
if(compareURL(redirec_uri))
break;
}
var hashStr = window.location.hash.substring(1);
var arr = hashStr.split('&');
var accessToken = arr[0];
return accessToken;
}
function compareURL(url)
{
if(window.location.href.substring(0, url.length) == url)
return true;
return false;
}
Any other way to wait for/detect that redirect to login_success?
If your browser crashes, it might be because an “infinite” loop is detected and the page becomes unresponsive. Maybe you should try