DarkLite1
DarkLite1

Reputation: 14745

How to use the googleapis in Vue Quasar with a Google Service Account

We're trying to retrieve calendar events using a Google Service Account.

We followed the steps to create a Google Service Account for authentication and downloaded the auth.json file. According to the Google docs it is sufficient to set an env variable:

File '.env'

GOOGLE_APPLICATION_CREDENTIALS='./auth.json'

File 'IndexPage.vue'

<script setup lang="ts">
   import { google } from 'googleapis'

   const calendar = google.calendar('v3')

To avoid the warning 'Module "stream" has been externalized for browser compatibility. Cannot access "stream.prototype" in client code.' we had to enable the nodePolyfills for Vite.

At this point we get the errors:

[Vue Router warn]: uncaught error during route navigation

TypeError: Cannot read properties of undefined (reading 'slice') at node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_writable.js (googleapis.js?v=266dd155:30236:85)

We're a bit at a loss here on how to get the authentication working to retrieve calendar events. We do need a Service Account because we need to avoid the user consent screen.

Sandbox for testing

Upvotes: 0

Views: 38

Answers (0)

Related Questions