How to use the gcp-metadata.HEADER_NAME function in gcp-metadata

To help you get started, we’ve selected a few gcp-metadata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / gcp-metadata / system-test / fixtures / kitchen / src / index.ts View on Github external
/**
 * Copyright 2018 Google LLC
 *
 * Distributed under MIT license.
 * See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
 */

import * as gcp from 'gcp-metadata';
// uncomment the line below during development
//import * as gcp from '../../../../build/src/index';

const header = gcp.HEADER_NAME;
const headers = gcp.HEADERS;

async function main() {
  const v = await gcp.instance('/somepath');
}

gcp.project('something').then(console.log);

main().catch(console.error);
github ruslang02 / atomos / node_modules / google-auth-library / build / src / auth / computeclient.js View on Github external
return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        url = this.tokenUrl ||
                            "" + gcpMetadata.HOST_ADDRESS + Compute._GOOGLE_OAUTH2_TOKEN_URL;
                        res = null;
                        _b.label = 1;
                    case 1:
                        _b.trys.push([1, 3, , 4]);
                        return [4 /*yield*/, ax.request({
                                url: url,
                                headers: (_a = {}, _a[gcpMetadata.HEADER_NAME] = 'Google', _a),
                                raxConfig: { noResponseRetries: 3, retry: 3, instance: ax }
                            })];
                    case 2:
                        // TODO: In 2.0, we should remove the ability to configure the tokenUrl,
                        // and switch this over to use the gcp-metadata package instead.
                        res = _b.sent();
                        return [3 /*break*/, 4];
                    case 3:
                        e_1 = _b.sent();
                        e_1.message = 'Could not refresh access token.';
                        throw e_1;
                    case 4:
                        tokens = res.data;
                        if (res.data && res.data.expires_in) {
                            tokens.expiry_date =
                                ((new Date()).getTime() + (res.data.expires_in * 1000));

gcp-metadata

Get the metadata from a Google Cloud Platform environment

Apache-2.0
Latest version published 6 months ago

Package Health Score

87 / 100
Full package analysis