GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — Add support for detecting project ID. Fixes #97 by jmdobry · Pull Request #98 · googleapis/google-auth-library-nodejs
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
Conversation
|
|
What do you think about putting the project ID as a property on the authClient / a getter? Since users of the library are likely caching the authClient, it should be easier for them to just grab the projectId off of that object as opposed to additionally caching the projectId returned when they create the client. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
They are related but still separate concerns. One is a set of credentials (a json key file), the other an identifier for a project. The // Get just the project ID auth.getDefaultProjectId(function (err, projectId) { // The project ID has now been cached console.log(auth._cachedProjectId === projectId); // true }); // Retrieve credentials and the project id auth.getApplicationDefault(function (err, credentials, projectId) { // Both are cached console.log(auth._cachedCredential === credentials); // true console.log(auth._cachedProjectId === projectId); // true }); This is how python is implementing it: import google.auth credentials, project_id = google.auth.default() |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think the functionality of auto-detection of a project ID is quite helpful, and I think users will appreciate it, too. My thought is we should make it as easy as possible for them to get by putting it on the authClient instance so they don't have to "catch it before it's gone" (in the callback of the auth client fetcher). But either way, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It won't be gone, it's cached on the
👍, though personally I would have function addScope(err, authClient, projectId) { if (err) { callback(err); return; } if (authClient.createScopedRequired && authClient.createScopedRequired()) { // ... } self.authClient = authClient; self.projectId = projectId; callback(null, authClient, projectId); } Then |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I guess all I'm really saying is it shouldn't be "private". In JS, the leading
Yep, that's exactly how I would do it :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
So perhaps we should also add synchronous getters to google-auth-library-nodejs for the credentials and projectId |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Can we also read the project_id from a service account keyfile? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Is that in the case I don't have |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Yeah, newer Service Account key files have a
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Does this library accept a key file path provided directly as a string, though? This is how I do it in google-auto-auth, but I'm not sure if I'm doing it in a way that this library intended to support. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Passing
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Coverage increased (+0.3%) to 92.673% when pulling 6921be6 on jmdobry:default-project into 02f5874 on google:master. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jmdobry what's the process for getting this shipped? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm not sure. Wishing I had write access. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.