// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/domainsrdap.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const domainsrdap = google.domainsrdap('v1');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await domainsrdap.nameserver.get({
nameserverId: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "description": [],
// "errorCode": 0,
// "jsonResponse": {},
// "lang": "my_lang",
// "notices": [],
// "rdapConformance": [],
// "title": "my_title"
// }
}
main().catch(e => {
console.error(e);
throw e;
});
const {google} = require('googleapis');
const domainsrdap = google.domainsrdap('v1');
// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/domainsrdap.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const domainsrdap = google.domainsrdap('v1');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await domainsrdap.ip.get({
ipId: 'placeholder-value',
ipId1: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "description": [],
// "errorCode": 0,
// "jsonResponse": {},
// "lang": "my_lang",
// "notices": [],
// "rdapConformance": [],
// "title": "my_title"
// }
}
main().catch(e => {
console.error(e);
throw e;
});
// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/domainsrdap.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const domainsrdap = google.domainsrdap('v1');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await domainsrdap.getEntities({});
console.log(res.data);
// Example response
// {
// "description": [],
// "errorCode": 0,
// "jsonResponse": {},
// "lang": "my_lang",
// "notices": [],
// "rdapConformance": [],
// "title": "my_title"
// }
}
main().catch(e => {
console.error(e);
throw e;
});
const { GoogleAuth, Impersonated } = require('google-auth-library');
const { SecretManagerServiceClient } = require('@google-cloud/secret-manager');
async function main() {
// Acquire source credentials:
const auth = new GoogleAuth();
const client = await auth.getClient();
// Impersonate new credentials:
let targetClient = new Impersonated({
sourceClient: client,
targetPrincipal: 'impersonated-account@projectID.iam.gserviceaccount.com',
lifetime: 30,
delegates: [],
targetScopes: ['https://www.googleapis.com/auth/cloud-platform']
});
// Get impersonated credentials:
const authHeaders = await targetClient.getRequestHeaders();
// Do something with `authHeaders.Authorization`.
// Use impersonated credentials:
const url = 'https://www.googleapis.com/storage/v1/b?project=anotherProjectID'
const resp = await targetClient.request({ url });
for (const bucket of resp.data.items) {
console.log(bucket.name);
}
// Use impersonated credentials with google-cloud client library
// Note: this works only with certain cloud client libraries utilizing gRPC
// e.g., SecretManager, KMS, AIPlatform
// will not currently work with libraries using REST, e.g., Storage, Compute
const smClient = new SecretManagerServiceClient({
projectId: anotherProjectID,
auth: {
getClient: () => targetClient,
},
});
const secretName = 'projects/anotherProjectNumber/secrets/someProjectName/versions/1';
const [accessResponse] = await smClient.accessSecretVersion({
name: secretName,
});
const responsePayload = accessResponse.payload.data.toString('utf8');
// Do something with the secret contained in `responsePayload`.
};
main();