oauth2-extensions icon indicating copy to clipboard operation
oauth2-extensions copied to clipboard

Undefined localStorage properties on initial load

Open dychen opened this issue 9 years ago • 0 comments

Whenever users first install the extension and it tries to OAuth, they get an invalid client id error (client id is undefined), presumably because the config data is written to localStorage after authorize() gets called. The quick fix I've made on my end is to pass an additional callback parameter to the OAuth2 constructor that gets called with the OAuth2 scope after instantiation instead of the suggested flow:

/* Before */
var googleAuth = new OAuth2('google', configHash);
googleAuth.authorize(function() {
  // Ready for action
});
/* After */
new OAuth2('google', configHash, function(auth) {
  auth.authorize(function() {
    // Ready for action
  }
});

Thoughts?

dychen avatar Jul 13 '15 20:07 dychen