Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not exist in type 'CredentialBody | ExternalAccountClientOptions' #2385

Closed
Shidooo opened this issue Dec 24, 2023 · 4 comments
Closed
Assignees
Labels
api: storage Issues related to the googleapis/nodejs-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: docs Improvement to the documentation for an API.

Comments

@Shidooo
Copy link

Shidooo commented Dec 24, 2023

Environment details

  • OS: Windows
  • Node.js version: 16.14.0
  • npm version: 8.3.1
  • @google-cloud/storage version: 7.7.0

Problem

Can't create a client with credentials passed by value as a JavaScript object like the documentation mentioned.

  private readonly STORAGE = new Storage({
    projectId: 'your-project-id',
    credentials: {
      type: 'service_account',
      project_id: 'xxxxxxx',
      private_key_id: 'xxxx',
      private_key:'-----BEGIN PRIVATE KEY-----xxxxxxx\n-----END PRIVATE KEY-----\n',
      client_email: 'xxxx',
      client_id: 'xxx',
      auth_uri: 'https://accounts.google.com/o/oauth2/auth',
      token_uri: 'https://oauth2.googleapis.com/token',
      auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
      client_x509_cert_url: 'xxx',
      }
    });

When I'm following documentation, my IDE tells on private_key_id:

Object literal may only specify known properties, and 'private_key_id' does not exist in type 'CredentialBody | ExternalAccountClientOptions'.ts(2353)
googleauth.d.ts(52, 5): The expected type comes from property 'credentials' which is declared here on type 'StorageOptions'

As well for : private_key_id, auth_uri, token_uri, auth_provider_x509_cert_url, client_x509_cert_url

Expected behavior

Works as described in the documentation.

Thanks

@Shidooo Shidooo added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 24, 2023
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Dec 24, 2023
@ddelgrosso1 ddelgrosso1 self-assigned this Dec 28, 2023
@ddelgrosso1
Copy link
Contributor

Hi @Shidooo it looks like the docs were never updated with changes to the auth client. I will get them updated. As you noted, those fields no longer exist.

@ddelgrosso1 ddelgrosso1 added type: docs Improvement to the documentation for an API. and removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 28, 2023
@ddelgrosso1
Copy link
Contributor

@danielbankhead in looking into this it also appears that the docs for auth might also be out of date: https://github.com/googleapis/google-auth-library-nodejs/blob/7ae4aaea0311de1a3e10f4e86a1ef93ff00656b5/README.md?plain=1#L296 looks like a lot of those fields no longer exist.

@danielbankhead
Copy link
Contributor

danielbankhead commented Jan 3, 2024

Turns out this is a small bug in GoogleAuth's constructor parameters. Currently the GoogleAuthOptions.credentials type parameter is more limited in properties than the GoogleAuth#fromJSON method, although in their code paths are used in the exact same way.

Here's a PR to resolve:

However, some fields aren't directly used in the google-auth-library, but are used with glcoud. These can be omitted for now:

  • auth_uri
  • token_uri
  • auth_provider_x509_cert_url
  • client_x509_cert_url

@danielbankhead
Copy link
Contributor

Fixed upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: docs Improvement to the documentation for an API.
Projects
None yet
Development

No branches or pull requests

3 participants