Cloud Channel API: Node.js Client
Channel client for Node.js
A comprehensive list of changes in each version may be found inthe CHANGELOG.
- Cloud Channel API Node.js Client API Reference
- Cloud Channel API Documentation
- github.com/googleapis/google-cloud-node/packages/google-cloud-channel
Read more about the client libraries for Cloud APIs, including the olderGoogle APIs Client Libraries, inClient Libraries Explained.
Table of contents:
Quickstart
Before you begin
- Select or create a Cloud Platform project.
- Enable billing for your project.
- Enable the Cloud Channel API API.
- Set up authentication so you can access theAPI from your local workstation.
Installing the client library
npm install @google-cloud/channelUsing the client library
// Reads the secrets from a `oauth2.keys.json` file, which should be downloaded// from the Google Developers Console and saved in the same directory with the// sample app.// This sample app only calls read-only methods from the Channel API. Include// additional scopes if calling methods that modify the configuration.const SCOPES = ['https://www.googleapis.com/auth/apps.order'];async function listCustomers(authClient, accountNumber) { // Imports the Google Cloud client library const {CloudChannelServiceClient} = require('@google-cloud/channel'); // Instantiates a client using OAuth2 credentials. const sslCreds = grpc.credentials.createSsl(); const credentials = grpc.credentials.combineChannelCredentials( sslCreds, grpc.credentials.createFromGoogleCredential(authClient) ); // Instantiates a client const client = newCloudChannelServiceClient({ sslCreds: credentials, }); // Calls listCustomers() method const customers = await client.listCustomers({ parent: `accounts/${accountNumber}`, }); console.info(customers);}/** * Create a new OAuth2Client, and go through the OAuth2 content * workflow. Return the full client to the callback. */function getAuthenticatedClient(keys) { return new Promise((resolve, reject) => { // Create an oAuth client to authorize the API call. Secrets are kept in a // `keys.json` file, which should be downloaded from the Google Developers // Console. const oAuth2Client = new OAuth2Client( keys.web.client_id, keys.web.client_secret, // The first redirect URL from the `oauth2.keys.json` file will be used // to generate the OAuth2 callback URL. Update the line below or edit // the redirect URL in the Google Developers Console if needed. // This sample app expects the callback URL to be // 'http://localhost:3000/oauth2callback' keys.web.redirect_uris[0] ); // Generate the url that will be used for the consent dialog. const authorizeUrl = oAuth2Client.generateAuthUrl({ access_type: 'offline', scope: SCOPES.join(' '), }); // Open an http server to accept the oauth callback. In this example, the // only request to our webserver is to /oauth2callback?code=<code> const server = http .createServer(async (req, res) => { try { if (req.url.indexOf('/oauth2callback') > -1) { // Acquire the code from the querystring, and close the web // server. const qs = new url.URL(req.url, 'http://localhost:3000') .searchParams; const code = qs.get('code'); console.log(`Code is ${code}`); res.end('Authentication successful! Please return to the console.'); server.destroy(); // Now that we have the code, use that to acquire tokens. const r = await oAuth2Client.getToken(code); // Make sure to set the credentials on the OAuth2 client. oAuth2Client.setCredentials(r.tokens); console.info('Tokens acquired.'); resolve(oAuth2Client); } } catch (e) { reject(e); } }) .listen(3000, () => { // Open the browser to the authorize url to start the workflow. // This line will not work if you are running the code in the // environment where a browser is not available. In this case, // copy the URL and open it manually in a browser. console.info(`Opening the browser with URL: ${authorizeUrl}`); open(authorizeUrl, {wait: false}).then(cp => cp.unref()); }); destroyer(server); });}async function main(accountNumber, keys) { // TODO: uncomment with your account number // const accountNumber = '1234' // TODO: uncomment this line with your oAuth2 file //const keys = require('./oauth2.keys.json'); getAuthenticatedClient(keys).then(authClient => listCustomers(authClient, accountNumber) );}Samples
Samples are in thesamples/ directory. Each sample'sREADME.md has instructions for running its sample.
| Sample | Source Code | Try it |
|---|---|---|
| Cloud_channel_reports_service.fetch_report_results | source code | ![]() |
| Cloud_channel_reports_service.list_reports | source code | ![]() |
| Cloud_channel_reports_service.run_report_job | source code | ![]() |
| Cloud_channel_service.activate_entitlement | source code | ![]() |
| Cloud_channel_service.cancel_entitlement | source code | ![]() |
| Cloud_channel_service.change_offer | source code | ![]() |
| Cloud_channel_service.change_parameters | source code | ![]() |
| Cloud_channel_service.change_renewal_settings | source code | ![]() |
| Cloud_channel_service.check_cloud_identity_accounts_exist | source code | ![]() |
| Cloud_channel_service.create_channel_partner_link | source code | ![]() |
| Cloud_channel_service.create_channel_partner_repricing_config | source code | ![]() |
| Cloud_channel_service.create_customer | source code | ![]() |
| Cloud_channel_service.create_customer_repricing_config | source code | ![]() |
| Cloud_channel_service.create_entitlement | source code | ![]() |
| Cloud_channel_service.delete_channel_partner_repricing_config | source code | ![]() |
| Cloud_channel_service.delete_customer | source code | ![]() |
| Cloud_channel_service.delete_customer_repricing_config | source code | ![]() |
| Cloud_channel_service.get_channel_partner_link | source code | ![]() |
| Cloud_channel_service.get_channel_partner_repricing_config | source code | ![]() |
| Cloud_channel_service.get_customer | source code | ![]() |
| Cloud_channel_service.get_customer_repricing_config | source code | ![]() |
| Cloud_channel_service.get_entitlement | source code | ![]() |
| Cloud_channel_service.import_customer | source code | ![]() |
| Cloud_channel_service.list_channel_partner_links | source code | ![]() |
| Cloud_channel_service.list_channel_partner_repricing_configs | source code | ![]() |
| Cloud_channel_service.list_customer_repricing_configs | source code | ![]() |
| Cloud_channel_service.list_customers | source code | ![]() |
| Cloud_channel_service.list_entitlement_changes | source code | ![]() |
| Cloud_channel_service.list_entitlements | source code | ![]() |
| Cloud_channel_service.list_offers | source code | ![]() |
| Cloud_channel_service.list_products | source code | ![]() |
| Cloud_channel_service.list_purchasable_offers | source code | ![]() |
| Cloud_channel_service.list_purchasable_skus | source code | ![]() |
| Cloud_channel_service.list_sku_group_billable_skus | source code | ![]() |
| Cloud_channel_service.list_sku_groups | source code | ![]() |
| Cloud_channel_service.list_skus | source code | ![]() |
| Cloud_channel_service.list_subscribers | source code | ![]() |
| Cloud_channel_service.list_transferable_offers | source code | ![]() |
| Cloud_channel_service.list_transferable_skus | source code | ![]() |
| Cloud_channel_service.lookup_offer | source code | ![]() |
| Cloud_channel_service.provision_cloud_identity | source code | ![]() |
| Cloud_channel_service.query_eligible_billing_accounts | source code | ![]() |
| Cloud_channel_service.register_subscriber | source code | ![]() |
| Cloud_channel_service.start_paid_service | source code | ![]() |
| Cloud_channel_service.suspend_entitlement | source code | ![]() |
| Cloud_channel_service.transfer_entitlements | source code | ![]() |
| Cloud_channel_service.transfer_entitlements_to_google | source code | ![]() |
| Cloud_channel_service.unregister_subscriber | source code | ![]() |
| Cloud_channel_service.update_channel_partner_link | source code | ![]() |
| Cloud_channel_service.update_channel_partner_repricing_config | source code | ![]() |
| Cloud_channel_service.update_customer | source code | ![]() |
| Cloud_channel_service.update_customer_repricing_config | source code | ![]() |
| Quickstart | source code | ![]() |
TheCloud Channel API Node.js Client API Reference documentationalso contains samples.
Supported Node.js Versions
Our client libraries follow theNode.js release schedule.Libraries are compatible with all currentactive andmaintenance versions ofNode.js.If you are using an end-of-life version of Node.js, we recommend that you updateas soon as possible to an actively supported LTS version.
Google's client libraries support legacy versions of Node.js runtimes on abest-efforts basis with the following warnings:
- Legacy versions are not tested in continuous integration.
- Some security patches and features cannot be backported.
- Dependencies cannot be kept up-to-date.
Client libraries targeting some end-of-life versions of Node.js are available, andcan be installed through npmdist-tags.The dist-tags follow the naming conventionlegacy-(version).For example,npm install @google-cloud/channel@legacy-8 installs client librariesfor versions compatible with Node.js 8.
Versioning
This library followsSemantic Versioning.
This library is considered to bestable. The code surface will not change in backwards-incompatible waysunless absolutely necessary (e.g. because of critical security issues) or withan extensive deprecation period. Issues and requests againststable librariesare addressed with the highest priority.
More Information:Google Cloud Platform Launch Stages
Contributing
Contributions welcome! See theContributing Guide.
Please note that thisREADME.md, thesamples/README.md,and a variety of configuration files in this repository (including.nycrc andtsconfig.json)are generated from a central template. To edit one of these files, make an editto its templates indirectory.
License
Apache Version 2.0
SeeLICENSE
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-09 UTC.
