# I failed developing a Google Assistant app

**URL:** <https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730>\
**Category:** Developers\
**Tags:** app, virtual-device, googlehome\
**Created:** [April 5, 2024, 9:28pm UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730 "2024-04-05T21:28:46Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielvanBreda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/danielvanbreda/32/79186_2.png) [@DanielvanBreda](https://community.homey.app/u/DanielvanBreda)\
**Post date:** [April 5, 2024, 9:28pm UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/1 "2024-04-05T21:28:46Z")

</div>

Hi all,

I spent two days trying to build a Google Assistant app, to use Homey to send a text command to GA.

I got a bit frustrated no being able to let my Hubs and Nest play Spotify music, so i figured i could make a app that could send a textQuery (_Play album X on cast device Y_) with this library:

> **[google-assistant](https://www.npmjs.com/package/google-assistant)**
>
> node.js port of the 3rd party Google Assistant SDK. Latest version: 0.7.0, last published: 3 years ago. Start using google-assistant in your project by running \`npm i google-assistant\`. There are 5 other projects in the npm registry using...

But i couldn’t get the oAuth to work because of my lacky experience with NodeJS. Maybe someone else has the same need for a “missing link” app like this, so thats why i’m sharing my frustrated development experience 😄

I figured it shouldn’t be to hard for a more experienced developer to make this work:

Cheers, Daniel

 ![IMG_4183](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/c/ac7e9bc3f74eb1d72a191a3abef569370420c691.png)

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [April 6, 2024, 6:52am UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/2 "2024-04-06T06:52:11Z")

</div>

Hi. just linking to the other similar post.  
Use this documentation and npm package from Athom to get all oAuth logic for free 🙂

> [@Assistance Requested: OAuth2 Authentication for Device Integration](https://community.homey.app/t/assistance-requested-oauth2-authentication-for-device-integration/107052/2):
>
> Check the manuals: Install the npm package and follow the example… and with only defining the clientId/secet and auth URL you can get all to work without any coding slight_smile

---

<div class="post-metadata">

**Author:** ![DanielvanBreda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/danielvanbreda/32/79186_2.png) [@DanielvanBreda](https://community.homey.app/u/DanielvanBreda)\
**Post date:** [April 9, 2024, 12:55pm UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/3 "2024-04-09T12:55:23Z")

</div>

Hi @RonnyW,

Thanks for your reply, i did try those links but i couldn’t get it to work for Google 😅 I hope that someone would check out my git repository and see what i’m doing wrong:

> **[GitHub - thadrax/nl.danielvanbreda.gaquery](https://github.com/thadrax/nl.danielvanbreda.gaquery)**
>
> Contribute to thadrax/nl.danielvanbreda.gaquery development by creating an account on GitHub.

I think i’m messing up in the driver.ts file:

> <https://github.com/thadrax/nl.danielvanbreda.gaquery/blob/main/drivers/google-assistant-driver/driver.ts>

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [April 9, 2024, 2:57pm UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/4 "2024-04-09T14:57:10Z")

</div>

Where did you get an error or when?  
Did you debug onto the auth/code exchange functions of the oAuthClient?  
Is teh oAuth popup shown? Can you proceed?

What I’ve seen:

`static API_URL = 'https://accounts.google.com/o/oauth2/auth?response_type=code&';`  
API\_URL is the URL to call API services with your bearer token. It’s not for oAuth. I think this should be the Server for your assistant API.

An in your oAuthClient you call:

```auto
await this.post({
      path: '/api/1/...',
      json:{}
    });

```

and the API\_URL is used as host.

---

<div class="post-metadata">

**Author:** ![DanielvanBreda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/danielvanbreda/32/79186_2.png) [@DanielvanBreda](https://community.homey.app/u/DanielvanBreda)\
**Post date:** [April 15, 2024, 8:56am UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/5 "2024-04-15T08:56:45Z")

</div>

> [@RonnyW](#):
>
> `/api/1/`

Hi @RonnyW,

I get an popup, but i get this response:

 ![Scherm­afbeelding 2024-04-15 om 10.53.32](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/c/ac1af3df0cbec728f460f801633a2d88dd7e8ea8.jpeg)

When i copy the response from google from the console, i get this html:

 ![Scherm­afbeelding 2024-04-15 om 10.55.24](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/1/0197ae21effcc41182ea25fd104e57d91b0318ab.png)

But it actually receives these parameters:

PARAMS {  
client\_id: ‘[361248910627-sbt2ehglhgptp0ksjqfgk1cv32f1162l.apps.googleusercontent.com](http://361248910627-sbt2ehglhgptp0ksjqfgk1cv32f1162l.apps.googleusercontent.com)’,  
redirect\_uri: ‘[https://callback.athom.com/oauth2/callback](https://callback.athom.com/oauth2/callback)’,  
scope: ‘[https://www.googleapis.com/auth/userinfo.profile](https://www.googleapis.com/auth/userinfo.profile) [https://www.googleapis.com/auth/userinfo.email](https://www.googleapis.com/auth/userinfo.email)’  
}

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [April 15, 2024, 10:19am UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/6 "2024-04-15T10:19:25Z")

</div>

You defined the redirect URL in your MyBrandOAuth2Client.ts. Looks ok.  
But your driver raises an execption fot “things”. The “things” function is only an example where you can call your API.

I’m not sure what you are doing here: [nl.danielvanbreda.gaquery/drivers/google-assistant-driver/driver.ts at main · thadrax/nl.danielvanbreda.gaquery · GitHub](https://github.com/thadrax/nl.danielvanbreda.gaquery/blob/main/drivers/google-assistant-driver/driver.ts#L108)

This list devices function is calles after oAuth process (oAuth is valid and you got your token) to read available devices you can add to Homey. I don’t know what “devices” you have for this API.

You oAuthClient redefinition should provide functions to read the API. The oAuthClient has access to the token etc.  
Example: [homey.tesla/lib/TeslaOAuth2Client.js at main · RonnyWinkler/homey.tesla · GitHub](https://github.com/RonnyWinkler/homey.tesla/blob/main/lib/TeslaOAuth2Client.js)  
In your driver, just call the method of your oAuthClient like this: [homey.tesla/drivers/car/driver.js at main · RonnyWinkler/homey.tesla · GitHub](https://github.com/RonnyWinkler/homey.tesla/blob/main/drivers/car/driver.js)

---

<div class="post-metadata">

**Author:** ![DanielvanBreda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/danielvanbreda/32/79186_2.png) [@DanielvanBreda](https://community.homey.app/u/DanielvanBreda)\
**Post date:** [April 15, 2024, 9:01pm UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/7 "2024-04-15T21:01:22Z")

</div>

Hi @RonnyW

Thank you so much for all your help, i’m beginning to understand more and more of how this works thanks to you. NodeJS is a bit out of my comfort zone, but its nice to learn.

I now got the oauth authorization working, now i’m gonna figure out how to call that authorization in my app.ts or how i can move my query flow to the virtual Google Assistant device.

> <https://github.com/thadrax/nl.danielvanbreda.gaquery/blob/main/app.ts>

Thanks once more 😄

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [April 16, 2024, 5:16am UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/8 "2024-04-16T05:16:05Z")

</div>

You’re welcome 😀  
And I know the difficulty to learn a nuw language, the SKD and oAuth on top 😅

---

<div class="post-metadata">

**Author:** ![DanielvanBreda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/danielvanbreda/32/79186_2.png) [@DanielvanBreda](https://community.homey.app/u/DanielvanBreda)\
**Post date:** [April 17, 2024, 9:33am UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/9 "2024-04-17T09:33:02Z")

</div>

Hi @RonnyW

Would you happen to know how to fix this grpc error:

> <https://github.com/thadrax/nl.danielvanbreda.gaquery/blob/main/drivers/google-assistant-driver/driver.ts>

grpc is deprecated and now grpc-js is used. But google-assistant uses grpc, and now throws this error:

“googleCredentials.getRequestMetadata is not a function”

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [April 17, 2024, 9:38am UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/10 "2024-04-17T09:38:25Z")

</div>

> [@DanielvanBreda](#):
>
> But google-assistant uses grpc

[Does it?](https://github.com/endoplasmic/google-assistant/blob/33ac967ad3316c77bda6a37c897676e8bd7260f5/package.json#L29)

---

<div class="post-metadata">

**Author:** ![DanielvanBreda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/danielvanbreda/32/79186_2.png) [@DanielvanBreda](https://community.homey.app/u/DanielvanBreda)\
**Post date:** [April 17, 2024, 10:15am UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/11 "2024-04-17T10:15:47Z")

</div>

uhm no it doesn’t 😬  
i’m sorry for the confusion, i did not read well.

This is my terminal error when i pass MyBrandOAuth2Client as oauth2Client. it contains:

```auto
MyBrandOAuth2Client {
    _events: [Object: null prototype] {
      log: [Function (anonymous)],
      error: [Function (anonymous)],
      debug: [Function (anonymous)],
      save: [Function (anonymous)],
      destroy: [Function (anonymous)]
    },
    _eventsCount: 5,
    _maxListeners: undefined,
    homey: Homey {
      _events: [Object: null prototype],
      _eventsCount: 4,
      _maxListeners: undefined,
      dir: '/app',
      tmpdir: '/app/tmp',
      version: '10.3.4',
      platform: 'local',
      platformVersion: 2,
      env: {},
      manifest: [Object],
      app: [MyBrandApp],
      __readyResolve: [Function (anonymous)],
      __readyPromise: [Promise],
      _timers: Set(0) {},
      _destroyed: false,
      apps: [ManagerApps],
      arp: [ManagerArp],
      audio: [ManagerAudio],
      ble: [ManagerBLE],
      cloud: [ManagerCloud],
      clock: [ManagerClock],
      drivers: [ManagerDrivers],
      discovery: [ManagerDiscovery],
      flow: [ManagerFlow],
      geolocation: [ManagerGeolocation],
      i18n: [ManagerI18n],
      images: [ManagerImages],
      insights: [ManagerInsights],
      ledring: [ManagerLedring],
      nfc: [ManagerNFC],
      notifications: [ManagerNotifications],
      rf: [ManagerRF],
      settings: [ManagerSettings],
      speechInput: [ManagerSpeechInput],
      speechOutput: [ManagerSpeechOutput],
      zigbee: [ManagerZigBee],
      zwave: [ManagerZwave],
      api: [ManagerApi],
      __strings: [Object],
      __: [Function:__],
      [Symbol(kCapture)]: false
    },
    _tokenConstructor: [class OAuth2Token],
    _clientId: '???',
    _clientSecret: '???',
    _apiUrl: 'https://accounts.google.com/o/oauth2/auth?response_type=code&',
    _tokenUrl: 'https://oauth2.googleapis.com/token',
    _authorizationUrl: 'https://accounts.google.com/o/oauth2/auth',
    _redirectUrl: 'https://callback.athom.com/oauth2/callback',
    _scopes: [
      'https://www.googleapis.com/auth/userinfo.profile',
      'https://www.googleapis.com/auth/userinfo.email'
    ],
    _token: OAuth2Token {
      access_token: '???',
      refresh_token: null,
      token_type: 'Bearer',
      expires_in: 3599
    },
    _title: null,
    [Symbol(kCapture)]: false
  }
}

```

and throws this error:

```auto
in failed with error: googleCredentials.getRequestMetadata is not a function
    at callErrorFromStatus (/app/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client.js:420:73)
    at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
    at /app/node_modules/@grpc/grpc-js/build/src/resolving-call.js:129:78
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
for call at
    at ServiceClientImpl.makeBidiStreamRequest (/app/node_modules/@grpc/grpc-js/build/src/client.js:404:32)
    at ServiceClientImpl.converse (/app/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
    at new Conversation (/app/node_modules/google-assistant/components/conversation.js:136:34)
    at GoogleAssistant.start (/app/node_modules/google-assistant/index.js:49:26)
    at GoogleAssistant.<anonymous> (/app/drivers/google-assistant-driver/driver.js:99:42)
    at GoogleAssistant.emit (node:events:513:28)
    at assistantReady (/app/node_modules/google-assistant/index.js:22:12)
    at processTicksAndRejections (node:internal/process/task_queues:78:11) {

```

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [April 17, 2024, 10:19am UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/12 "2024-04-17T10:19:05Z")

</div>

> <https://github.com/grpc/grpc-node/issues/545>
>
> We're using an old version of google-auth-library, which throws deprecation warn…ings for the \`getRequestMetadata\` method. We need to update to \`2.0.0\`, and use the \`getRequestHeaders\` method instead. 
> 
> For details on the upgrade, see \[the changelog\](https://github.com/googleapis/google-auth-library-nodejs/releases/tag/v2.0.0).

Also: [Release v2.0.0 · googleapis/google-auth-library-nodejs · GitHub](https://github.com/googleapis/google-auth-library-nodejs/releases/tag/v2.0.0)

---

<div class="post-metadata">

**Author:** ![DanielvanBreda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/danielvanbreda/32/79186_2.png) [@DanielvanBreda](https://community.homey.app/u/DanielvanBreda)\
**Post date:** [April 17, 2024, 3:38pm UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/13 "2024-04-17T15:38:37Z")

</div>

Ah so should i try to update the google-auth-library dependency?  
I tried that this way, but the google-auth-library dependency within google-assistant remains ^7.0.4 instead of ^9.8.0 🙃

> <https://github.com/thadrax/nl.danielvanbreda.gaquery/blob/main/package.json>

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [April 17, 2024, 5:28pm UTC](https://community.homey.app/t/i-failed-developing-a-google-assistant-app/107730/14 "2024-04-17T17:28:09Z")

</div>

I think you should get rid of the override, since it clearly doesn’t work. If you can’t get `google-assistant` to work you may have to consider looking for an alternative, it’s been a couple of years since it was last updated so it may be deprecated itself.
