{"id":2197,"date":"2022-08-30T15:22:51","date_gmt":"2022-08-30T15:22:51","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/04\/chrome-app-extension-not-working-with-oauth-javascript-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:22:51","modified_gmt":"2022-08-30T15:22:51","slug":"chrome-app-extension-not-working-with-oauth-javascript-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/chrome-app-extension-not-working-with-oauth-javascript-collection-of-common-programming-errors\/","title":{"rendered":"Chrome App Extension not working with Oauth Javascript-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m getting this error &#8220;Uncaught TypeError: Cannot call method &#8216;setBadgeText&#8217; of undefined &#8220;<\/p>\n<p>This is my code below:<\/p>\n<p>This used to work in Chrome 27.0, but now with Chrome 29.0 it seems to have stopped functioning. I&#8217;m not sure if it&#8217;s this or the.. manifest.json file which loads this in the background.<\/p>\n<pre><code>  var DOCLIST_SCOPE = 'https:\/\/docs.google.com\/feeds';\n  var DOCLIST_FEED = DOCLIST_SCOPE + '\/default\/private\/full\/';\n  var docs = []; \/\/ In memory cache for the user's entire doclist.\n  var refreshRate = localStorage.refreshRate || 300; \/\/ 5 min default.\n  var pollIntervalMin = 1000 * refreshRate;\n  var requests = [];\n\n  var oauth = ChromeExOAuth.initBackgroundPage({\n    'request_url': 'https:\/\/www.google.com\/accounts\/OAuthGetRequestToken',\n    'authorize_url': 'https:\/\/www.google.com\/accounts\/OAuthAuthorizeToken',\n    'access_url': 'https:\/\/www.google.com\/accounts\/OAuthGetAccessToken',\n    'consumer_key': 'anonymous',\n    'consumer_secret': 'anonymous',\n    'scope': DOCLIST_SCOPE,\n    'app_name': 'App Name'\n  });\n\n  function setIcon(opt_badgeObj) {\n    if (opt_badgeObj) {\n      var badgeOpts = {};\n      if (opt_badgeObj &amp;&amp; opt_badgeObj.text != undefined) {\n        badgeOpts['text'] = opt_badgeObj.text;\n      }\n      if (opt_badgeObj &amp;&amp; opt_badgeObj.tabId) {\n        badgeOpts['tabId'] = opt_badgeObj.tabId;\n      }\n      chrome.browserAction.setBadgeText(badgeOpts);\n    }\n  };\n\n  function clearPendingRequests() {\n    for (var i = 0, req; req = requests[i]; ++i) {\n      window.clearTimeout(req);\n    }\n    requests = [];\n  };\n\n  function logout() {\n    docs = [];\n    setIcon({'text': ''});\n    oauth.clearTokens();\n    clearPendingRequests();\n  };\n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2014-01-04 14:17:36. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m getting this error &#8220;Uncaught TypeError: Cannot call method &#8216;setBadgeText&#8217; of undefined &#8220; This is my code below: This used to work in Chrome 27.0, but now with Chrome 29.0 it seems to have stopped functioning. I&#8217;m not sure if it&#8217;s this or the.. manifest.json file which loads this in the background. var DOCLIST_SCOPE = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2197","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2197"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2197\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}