googleapis / googleapis/google-api-nodejs-client

People searchContacts returns an empty object

Offen
#3,277 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
priority: p2 type: bug
Vorherrschende Sprache
TypeScript
Sterne
12.2k
Forks
2k
Ø Merge
1 T. 9 Std.
Gemergte PRs (30 T.)
24

Beschreibung

1) Is this a client library issue or a product issue?
library issue

2) Did someone already solve this?
nope

3) Do you have a support contract?
nope

If the support paths suggested above still do not result in a resolution, please provide the following details.

#### Environment details

- OS: Ubuntu 22.04
- Node.js version: 18.12.1
- npm version: 8.19.2
- `googleapis` version: 118.0.0

#### Steps to reproduce

```js
import path from 'node:path';
import fs from 'node:fs';
import { authenticate } from '@google-cloud/local-auth';
import { google } from 'googleapis';
import dotenv from 'dotenv';

dotenv.config();

const keyFile = path.join(path.resolve(), './client.oauth2.keys.json');

const people = google.people('v1');

const auth = new google.auth.GoogleAuth({
keyFile: path.join(path.resolve(), 'chatter-cal-1cfb9a3e830d.json'),
scopes: ['https://www.googleapis.com/auth/contacts'],
});

google.options({ auth });

export const searchContact = async (phoneNumber) => {
// https://developers.google.com/people/api/rest/v1/people/searchContacts
const response = await people.people.searchContacts(
{
query: phoneNumber,
readMask: 'names,phoneNumbers',
key: process.env.GOOGLE_PEOPLE_API_KEY,
},
{
headers: {
'X-Goog-Encode-Response-If-Executable': 'base64',
},
}
);

console.log('\n\nResponse:', JSON.stringify(response, null, 2));
return response;
};
```
This is the response:
```json
{
"config": {
"url": "https://people.googleapis.com/v1/people:searchContacts?query=&readMask=names%2CphoneNumbers&key=*****",
"method": "GET",
"headers": {
"X-Goog-Encode-Response-If-Executable": "base64",
"x-goog-api-client": "gdcl/6.0.4 gl-node/18.12.1 auth/8.8.0",
"Accept-Encoding": "gzip",
"User-Agent": "google-api-nodejs-client/6.0.4 (gzip)",
"Authorization": "Bearer *****",
"Accept": "application/json"
},
"userAgentDirectives": [
{
"product": "google-api-nodejs-client",
"version": "6.0.4",
"comment": "gzip"
}
],
"params": {
"query":
,
"readMask": "names,phoneNumbers",
"key": "*****"
},
"retry": true,
"responseType": "json"
},
"data": {}, // <---------ALWAYS EMPTY
"headers": {
"alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000",
"cache-control": "private",
"connection": "close",
"content-encoding": "gzip",
"content-type": "application/json; charset=UTF-8",
"date": "Fri, 07 Jul 2023 07:22:50 GMT",
"server": "ESF",
"transfer-encoding": "chunked",
"vary": "Origin, X-Origin, Referer",
"x-content-type-options": "nosniff",
"x-frame-options": "SAMEORIGIN",
"x-xss-protection": "0"
},
"status": 200,
"statusText": "OK",
"request": {
"responseURL": "https://people.googleapis.com/v1/people:searchContacts?query=
&readMask=names%2CphoneNumbers&key=*****"
}
}
```

The auth seems fine, the scope is right, the number is absolutely in my contacts and the very same call works when done from this page with the same parameters: [People API Reference - Method: people.searchContacts](https://developers.google.com/people/api/rest/v1/people/searchContacts)

Am I missing something?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginnen Sie beim Einstiegspunkt people.people.searchContacts und reproduzieren Sie die Anfrage mit dem bereitgestellten Node.js-Beispiel und den Parametern. Vergleichen Sie die generierte Anfrage und die zurückgegebenen Daten mit der People API-Referenz, um festzustellen, ob das leere Objekt aus der Clientbibliothek oder dem Dienst stammt. Als abgeschlossen gilt die Aufgabe, wenn die verantwortliche Seite identifiziert und das Verhalten entsprechend dokumentiert oder korrigiert wurde.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
node.js, typescript
Bereich
api
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.