Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__awaiter is not defined #9

Closed
baruchiro opened this issue Feb 2, 2020 · 2 comments
Closed

__awaiter is not defined #9

baruchiro opened this issue Feb 2, 2020 · 2 comments

Comments

@baruchiro
Copy link
Contributor

Hi, I have an Electron + Vue project (no TypeScript), and when I trying to use your library, I'm getting the next error when I trying to openAuthWindowAndGetTokens:

ReferenceError: __awaiter is not defined
at ElectronGoogleOAuth2.openAuthPageAndGetAuthorizationCode (index.js?0322:85)
at ElectronGoogleOAuth2.openAuthWindowAndGetAuthorizationCode (index.js?0322:82)
at ElectronGoogleOAuth2.getAuthorizationCode (index.js?0322:74)
at ElectronGoogleOAuth2.openAuthWindowAndGetTokens (index.js?0322:122)
at _callee4$ (index.js?f1e9:22)
at tryCatch (runtime.js?96cf:62)
at Generator.invoke [as _invoke] (runtime.js?96cf:296)
at Generator.prototype.(:8081/anonymous function) [as next] (webpack-internal:///./node_modules/regenerator-runtime/runtime.js:114:21)
at asyncGeneratorStep (asyncToGenerator.js?1da1:3)
at _next (asyncToGenerator.js?1da1:25)

My code:

const clientDetails = require('./client_secret.json');
const myApiOauth = new ElectronGoogleOAuth2(
  clientDetails.client_id,
  clientDetails.client_secret,
  [
    'https://www.googleapis.com/auth/drive.metadata.readonly',
    'https://www.googleapis.com/auth/spreadsheets',
  ],
);

myApiOauth.on('tokens', async (tokens) => {
  if (tokens.refresh_token) {
    await saveToken(tokens);
  }
});

const savedToken = await loadToken();

if (savedToken !== null) {
  myApiOauth.setTokens(savedToken);
} else {
  try {
    const token = await myApiOauth.openAuthWindowAndGetTokens();
    await saveToken(token);
    myApiOauth.setTokens(token);
  } catch (err) {
    debugger;
    console.error(err);
  }
}

So I copied your code and removed all TypeScript references, and it works.
You can use this commit from my PR to reproduce the bug, just install your package with yarn and change the import:
https://github.com/baruchiro/israeli-bank-scrapers-desktop/blob/81792211d4dd8650f4a85d3aa37b39fdb636380a/src/modules/googleOauth/index.js#L1

@magne4000
Copy link
Member

@baruchiro I released a new version that should fix your issue, could you try it?

@baruchiro
Copy link
Contributor Author

Thanks! It solved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants