google-api-nodejs-client
google-api-nodejs-client copied to clipboard
Admin SDK API returns bad request 400 error
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
-
Is this a client library issue or a product issue? This is the client library for. We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers.
-
Did someone already solve this?
- Search the issues already opened: https://github.com/googleapis/google-api-nodejs-client/issues
- Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-node
- Search or ask on StackOverflow (engineers monitor these tags): http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- Do you have a support contract? Please create an issue in the support console to ensure a timely response.
If the support paths suggested above still do not result in a resolution, please provide the following details.
Environment details
- OS: ubuntu
- Node.js version: v12.22.3
- npm version: 6.14.13
googleapisversion: ^84.0.0
Steps to reproduce
- deploy the code on GCP
- and try to make any request like user.list or group.list etc
All code working yesterday, the problem we are facing from today morning, we did not change any code from our side
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!
to @vishalsharma-jft
Can you share your code sample?
Hmm ...
The next code returns Bad request
import { google, admin_directory_v1 } from 'googleapis';
import { authenticate } from '@google-cloud/local-auth';
import path from 'path';
import env from '../env.json';
(async () => {
const auth = await authenticate({
keyfilePath: path.join(__dirname, './..', env.WEB_CLIENT_OAUTH),
scopes: ['https://www.googleapis.com/auth/admin.directory.group'],
});
google.options({ auth });
const admin: admin_directory_v1.Admin = google.admin({
version: 'directory_v1',
auth: auth,
});
try {
const createResponse = await admin.groups.list({
userKey: env.DOMAIN_EFFECTIVE_USER_EMAIL,
});
console.log(createResponse.data);
} catch (err) {
console.log(err);
}
})();
may it could be related to https://github.com/googleapis/google-api-nodejs-client/issues/2789 as we also receive 400 status code.
Here is the Sample code
const service = google.admin('directory_v1'); service.users.list({ auth: jwtclient, customer: 'my_customer', orderBy: 'email', maxResults: 500, projection:'full', pageToken }, function (err, response) { })
Now, it's working fine automatically. the issue was coming when we deploy the code on GCP, otherwise there is no issue on the local machine
The similar issue in #2789 was resolved through dependency updates — since this issue seems quite stale, I'm going to make the (somewhat risky) assumption that this hasn't reoccured for folks. If that assumption is incorrect, please open a new issue to new repro steps, and thanks!