Socket
Socket
Sign inDemoInstall

googleapis-common

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

googleapis-common

A common tooling library used by the googleapis npm module. You probably don't want to use this directly.


Version published
Weekly downloads
906K
decreased by-61.22%
Maintainers
1
Weekly downloads
 
Created

What is googleapis-common?

The googleapis-common npm package provides common utilities and types for Google API clients. It is used internally by other Google API client libraries to handle common tasks such as authentication, request handling, and response parsing.

What are googleapis-common's main functionalities?

Authentication

This feature allows you to authenticate with Google APIs using the GoogleAuth class. The code sample demonstrates how to create an instance of GoogleAuth, obtain a client, and retrieve the project ID.

const { GoogleAuth } = require('googleapis-common');
const auth = new GoogleAuth({
  scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});

async function authenticate() {
  const client = await auth.getClient();
  const projectId = await auth.getProjectId();
  console.log(`Authenticated with project ID: ${projectId}`);
}
authenticate();

Request Handling

This feature provides a way to handle API requests using the createAPIRequest function. The code sample shows how to set up the parameters for a GET request to a hypothetical Google API endpoint and handle the response.

const { createAPIRequest } = require('googleapis-common');

async function makeRequest() {
  const parameters = {
    options: {
      url: 'https://www.googleapis.com/someapi/v1/resource',
      method: 'GET',
    },
    params: {},
    requiredParams: [],
    pathParams: [],
    context: {},
  };

  const response = await createAPIRequest(parameters);
  console.log(response.data);
}
makeRequest();

Response Parsing

This feature allows you to parse responses from Google API requests. The code sample demonstrates how to make a request and parse the response data.

const { createAPIRequest } = require('googleapis-common');

async function parseResponse() {
  const parameters = {
    options: {
      url: 'https://www.googleapis.com/someapi/v1/resource',
      method: 'GET',
    },
    params: {},
    requiredParams: [],
    pathParams: [],
    context: {},
  };

  const response = await createAPIRequest(parameters);
  const data = response.data;
  console.log(`Parsed data: ${JSON.stringify(data)}`);
}
parseResponse();

Other packages similar to googleapis-common

FAQs

Package last updated on 15 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc