oauth2-extensions
oauth2-extensions copied to clipboard
Undefined localStorage properties on initial load
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?