@maxim_mazurok/gapi.client.apikeys
TypeScript icon, indicating that this package has built-in type declarations

2.0.20220811 • Public • Published

TypeScript typings for API Keys API v2

Manages the API keys associated with developer projects. For detailed description please check documentation.

Installing

Install typings for API Keys API:

npm install @types/gapi.client.apikeys@v2 --save-dev

Usage

You need to initialize Google API client in your code:

gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:

gapi.client.load('apikeys', 'v2', () => {
  // now we can use gapi.client.apikeys
  // ...
});

Don't forget to authenticate your client before sending any request to resources:

// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [ 
      // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
      'https://www.googleapis.com/auth/cloud-platform',

      // View your data across Google Cloud services and see the email address of your Google Account
      'https://www.googleapis.com/auth/cloud-platform.read-only',
    ],
    immediate = true;
// ...

gapi.auth.authorize(
  { client_id: client_id, scope: scope, immediate: immediate },
  authResult => {
    if (authResult && !authResult.error) {
        /* handle successful authorization */
    } else {
        /* handle authorization error */
    }
});

After that you can use API Keys API resources:

/*
Find the parent project and resource name of the API key that matches the key string in the request. If the API key has been purged, resource name will not be set. The service account must have the `apikeys.keys.lookup` permission on the parent project.
*/
await gapi.client.apikeys.keys.lookupKey({  });

/*
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
*/
await gapi.client.apikeys.operations.get({ name: "name",  });

Readme

Keywords

none

Package Sidebar

Install

npm i @maxim_mazurok/gapi.client.apikeys

Weekly Downloads

170

Version

2.0.20220811

License

MIT

Unpacked Size

37.8 kB

Total Files

6

Last publish

Collaborators

  • maxim_mazurok