Getting metadata from plugin failed with error: unauthorized_client

750 views
Skip to first unread message

Marcos Colares

unread,
Oct 13, 2023, 4:41:38 AM10/13/23
to Google Ads API and AdWords API Forum
Hello everybody.

I'm developing a simple control panel that connects with the Google Ads API through NodeJS Backend. To configure the code, I followed Google's instructions to obtain the necessary credentials and the unauthorized_client error still returns, note that I left the "#" symbol so as not to show the real credentials here on the forum. The refresh_token can be obtained through https://developers.google.com/oauthplayground

Could you help me proceed with the Google Ads API connection step? I'll show you the initial NodeJS code:

import { GoogleAdsApi } from "google-ads-api";

// Replace these example credentials with your real credentials.
const client = new GoogleAdsApi({
  client_id: "#",
  client_secret: "#",
  developer_token: "#",
})

async function checkConnection() {
  const customer = client.Customer({
    customer_account_id: '#',
    refresh_token: '#',
  })

  try {
    // Try to retrieve some campaigns to check the connection.
    const campaigns = await customer.report({
      entity: 'campaign',
      attributes: ['campaign.id', 'campaign.name'],
      limit: 5, // Modify this number as needed
    })

    if (campaigns.length === 0) {
      console.log('No campaigns created at the moment');
    } else {
      console.log('API connected successfully');
    }
  } catch (err) {
    console.error('Error connecting to the API', err)
  }
}

checkConnection()


ERROR:
erro_googleapi.png

Google Ads API Forum Advisor

unread,
Oct 16, 2023, 5:44:16 AM10/16/23
to marcos...@buobe.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

By reviewing your concern, I understand that you are getting an unauthorized_client error while trying to connect to the Google Ads API.

In order to investigate your issue further, kindly provide us with the complete API logs (request and response with request-id and request header) along with the uncropped UI screenshot generated at your end.

If you are using a client library and haven't enabled logging yet, I would request that you enable logging for the specific client library that you are using. You can refer to the guides in Java.NetPHPPythonRuby, or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.

This message is in relation to case "ref:!00D1U01174p.!5004Q02pRLkx:ref"

Thanks,
 
Google Logo Google Ads API Team


 

Reply all
Reply to author
Forward
0 new messages