Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7918231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:26:06+00:00 2026-06-03T15:26:06+00:00

I build a Firefox Extension and i’m using the graph api. At the moment

  • 0

I build a Firefox Extension and i’m using the graph api. At the moment i catch the access token of each user while starting the browser like:
https://stackoverflow.com/questions/10301146/facebook-login-within-a-firefox-add-on

This works fine but kind of stupid, because nobody will use the extension in each firefox session. So what i’m trying to do is, catch the access token or more accurately call the methode Wladimir Palant recommends on demand. My code looks like this, while getAccessToken() is the mentioned method.

onLoad: function (){
   var NoteHandler = window.arguments[0];
   var sjcl = NoteHandler.sjcl;
   NoteHandler.getAccessToken();
   decryptionDialog.noteHandler = NoteHandler;
   decryptionDialog.sjcl = sjcl;

   var currID = decryptionDialog.getID();

   if(currID==""){
      window.close();
      return false;
     }else{             
       http_request = new XMLHttpRequest();   
       http_request.open('Get', 'https://graph.facebook.com/'+currID+'/notes?access_token='+NoteHandler.token, false);
       http_request.overrideMimeType("text/json");
       http_request.send(null);

       decryptionDialog.value = decryptionDialog.ResponseToArray(http_request.responseText);
....

But the problem is while getAccessToken() is still waiting for the access token, the onLoad()-Method won’t wait and goes on. Therefore the NoteHandler.token is null while the request is send. Does anyone have an idea, because i’m relatively new to javascript.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:26:07+00:00Added an answer on June 3, 2026 at 3:26 pm

    You should rewrite this code to be asynchronous – it shouldn’t assume that getAccessToken() will get the result immediately, there should be rather a callback parameter, a function to be called when the operation is done (can be a closure function). Something along these lines:

    onLoad: function (){
       var NoteHandler = window.arguments[0];
       var sjcl = NoteHandler.sjcl;
       NoteHandler.getAccessToken(function()
       {
           decryptionDialog.noteHandler = NoteHandler;
           decryptionDialog.sjcl = sjcl;
    
           ...
    
           http_request.open('Get', 'https://graph.facebook.com/'+currID+'/notes?access_token='+NoteHandler.token, false);
    
           ...
       });
    }
    
    ...
    
    getAccessToken: function(callback) {
        ...
    
        // All done - call the callback
        callback();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using some code to build up tables using JQuery, but in Firefox 3.5.3
I have to build a firefox extension and I want to be able to
I'm trying to build an extension for Firefox. This extension uses an XPCOM component
I'm using something similar to NodeJS called bondi, it's build on the Firefox js
I'm using the Firefox Addon SDK to build something that monitors and displays the
I'm trying to build an XPCOM extension for Firefox, and I need to build
I have a website build using PHP and HTML. If a user browses my
I'm developing xul extension that has access to a remote system. User must set
I just started using the FireFox Builder to build a simple addon. I realised
I'm trying to build an extension to Firefox to get a page from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.