google-api-nodejs-client icon indicating copy to clipboard operation
google-api-nodejs-client copied to clipboard

Admin SDK API returns bad request 400 error

Open vishalsharma-jft opened this issue 4 years ago • 4 comments

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.

  1. 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.

  2. 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
  1. 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
  • googleapis version: ^84.0.0

Steps to reproduce

  1. deploy the code on GCP
  2. 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!

vishalsharma-jft avatar Sep 21 '21 11:09 vishalsharma-jft

to @vishalsharma-jft

Can you share your code sample?

oshliaer avatar Sep 21 '21 14:09 oshliaer

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);
  }
})();

oshliaer avatar Sep 21 '21 15:09 oshliaer

may it could be related to https://github.com/googleapis/google-api-nodejs-client/issues/2789 as we also receive 400 status code.

jbpin avatar Sep 22 '21 11:09 jbpin

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

vishalsharma-jft avatar Sep 24 '21 02:09 vishalsharma-jft

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!

meredithslota avatar Aug 09 '23 23:08 meredithslota