Failed to integrate with googleapis

I tried to import googleapis and use it in my Forge app, but I got a deployment error like the below:

Error: Deployment failed
    at ArtifactDeployer.handleErrorEvent (C:\Users\Leo\AppData\Roaming\npm\node_modules\@forge\cli\out\deploy\deployer\deployer.js:151:15)
    at ArtifactDeployer.pollAndCheckEvents (C:\Users\Leo\AppData\Roaming\npm\node_modules\@forge\cli\out\deploy\deployer\deployer.js:61:18)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async ArtifactDeployer.monitorDeployment (C:\Users\Leo\AppData\Roaming\npm\node_modules\@forge\cli\out\deploy\deployer\deployer.js:72:28)
    at async ArtifactDeployer.deploy (C:\Users\Leo\AppData\Roaming\npm\node_modules\@forge\cli\out\deploy\deployer\deployer.js:36:9)
    at async PackageUploadDeployCommand.execute (C:\Users\Leo\AppData\Roaming\npm\node_modules\@forge\cli\out\deploy\package-upload-deploy.js:14:9)
    at async CommandLineUI.displayProgress (C:\Users\Leo\AppData\Roaming\npm\node_modules\@forge\cli\node_modules\@forge\cli-shared\out\ui\command-line-ui.js:44:28)  
    at async DeployView.reportDeploymentProgress (C:\Users\Leo\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\view\deploy-view.js:32:24)
    at async DeployController.run (C:\Users\Leo\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\controller\deploy-controller.js:70:27)
    at async Command.actionProcessor (C:\Users\Leo\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\command.js:74:32)

Here’s my code:

import { google } from 'googleapis';
...
const { client_secret, client_id, redirect_uris } = cred.installed;
const oAuth2Client = new google.auth.OAuth2(
  client_id,
  client_secret,
  redirect_uris[0]
);
...

App details:

  • Jira product-trigger
  • Node.js version tried: v16.2.0, v14.17.0, v14.15.0, v14.0.0
  • Dependencies: @forge/api, @forge/ui, googleapis, moment-timezone

Note: The app works perfectly without using googleapis.

Hi @vanlykim,

After doing some investigation, it looks like googleapis is not yet supported by Forge, as we have not yet implemented a crypto polyfill for the runtime your code runs in. We are exploring solutions here, but it hasn’t been a trivial issue so far. We don’t yet have a timeline for a fix.

Could you describe your use case for using googleapis? Perhaps in the meantime we could help you find a work around for achieving your use case.

3 Likes

@kchan We use googleapis for creating Google Calendar events from within our app.