1

I have tried to load OAuth.io js file downloaded from https://github.com/oauth-io/oauth-js/tree/master/dist using

Oauth = require("lib/oauth.min.js");

I got following error in debug console.

console.error: test: 
  Message: ReferenceError: window is not defined
  Stack:
    [8]</<@resource://jid1-rpqb40q3z1iksq-at-jetpack/nekt/lib/tplib/oauth.min.js:3:20165
[8]<@resource://jid1-rpqb40q3z1iksq-at-jetpack/nekt/lib/tplib/oauth.min.js:3:20107
e@resource://jid1-rpqb40q3z1iksq-at-jetpack/nekt/lib/tplib/oauth.min.js:3:212
a@resource://jid1-rpqb40q3z1iksq-at-jetpack/nekt/lib/tplib/oauth.min.js:3:387
@resource://jid1-rpqb40q3z1iksq-at-jetpack/nekt/lib/tplib/oauth.min.js:3:1
CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:79:18
Background@resource://jid1-rpqb40q3z1iksq-at-jetpack/nekt/lib/background.js:52:10

Please help me to use OAuth.io js file to authorize google using OAuth.

Valarpirai
  • 465
  • 3
  • 14

1 Answers1

1

It looks like you're trying to load it from background (main). Main in Firefox does not have a window object - which is why you're getting the error. It's a perfectly fine way of doing things in Chrome, as background in Chrome is also a page and has a window element, in Firefox though there's no window in the background.

If you want to use js code that needs a window in Main, you'll have to follow one these routes:

  • edit the code not to need window element
  • OR use page-worker to utilize it.
MeLight
  • 5,454
  • 4
  • 43
  • 67