google-api-nodejs-client
google-api-nodejs-client copied to clipboard
People searchContacts returns an empty object
-
Is this a client library issue or a product issue? library issue
-
Did someone already solve this? nope
-
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
googleapisversion: 118.0.0
Steps to reproduce
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:
{
"config": {
"url": "https://people.googleapis.com/v1/people:searchContacts?query=<A PHONE NUMBER IN MY CONTACTS>&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": <A PHONE NUMBER IN MY CONTACTS>,
"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=<A PHONE NUMBER IN MY CONTACTS>&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
Am I missing something?
I am sorry, any news about this?
Hi to all, any news about this bug? thanks
Please let us know if will be fixed, thanks