I'm trying to get a successful response when executing the request from https://developers.google.com/admin-sdk/directory/v1/reference/users/list?apix_params=%7B%22customer%22%3A%22my_customer%22%7D. I'm getting a 400 Invalid Input
response.
With the client library(https://www.npmjs.com/package/googleapis, v47), when calling:
google.admin('directory_v1')
.users.list({
auth: oAuth2Client,
customer: 'my_customer',
orderBy: 'email',
maxResults: 500,
pageToken: null
}).then(...);
, I'm receiving a Request
object in the success handler, instead of a valid response(response which should have had the shape described at the bottom of https://developers.google.com/admin-sdk/directory/v1/reference/users/list).
What am I doing wrong?
Turns out the issue was with the authentication process, using the google-auth-library
.
I've resorted to something like this:
const {google} = require('googleapis');
const oAuthClient = await google.auth.getClient({keyFile: ..., scopes: [...]});
oAuthClient.credentials = await new google.auth.JWT(...).authorizeAsync();
const {data} = await google
.admin({version: 'directory_v1', auth: oAuthClient})
.users
.list({
customer: 'my_customer'
});