const createAuthCredential = async () => { try { let authClient = await google.auth.getApplicationDefault(); authClient = authClient.credential; if (authClient.createScopedRequired && authClient.createScopedRequired()) { authClient = authClient.createScoped([ 'https://www.googleapis.com/auth/jobs', ]); } return google.jobs({ version: 'v3', auth: authClient, }); } catch (e) { return console.error(e); } }
google.auth.getApplicationDefault(function (err, authClient) { if (err) { console.error('authentication failed: ', err);
google.auth.getApplicationDefault((err, authClient) => { if (err) { callback(err);
google.auth.getApplicationDefault(function (err, authClient) { if (err) { console.error('authentication failed: ', err);
google.auth.getApplicationDefault((err, authClient) => { if (err) { console.error('Failed to acquire credentials');
google.auth.getApplicationDefault(function (err, authClient) { if (err) { console.error('authentication failed: ', err);
// [END setup] // [START auth] function auth(callback) { google.auth.getApplicationDefault((err, authClient) => { if (err) { return callback(err); } // The createScopedRequired method returns true when running on GAE or a // local developer machine. In that case, the desired scopes must be passed // in manually. When the code is running in GCE or GAE Flexible, the scopes // are pulled from the GCE metadata server. // See https://cloud.google.com/compute/docs/authentication for more // information. if (authClient.createScopedRequired && authClient.createScopedRequired()) { // Scopes can be specified either as an array or as a single, // space-delimited string. authClient = authClient.createScoped([ 'https://www.googleapis.com/auth/cloud-platform', ]); } callback(null, authClient); }); }
google.auth.getApplicationDefault(function (err, authClient) { if (err) { console.error('authentication failed: ', err);
google.auth.getApplicationDefault(function (err, authClient) { if (err) { console.error('authentication failed: ', err);
google.auth.getApplicationDefault(function (err, authClient) { if (err) { console.error('authentication failed: ', err);