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:
[image: erro_googleapi.png]
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/9fd315c5-bffb-46fe-be94-efd921259035n%40googlegroups.com.