Authentication scopes problem

120 views
Skip to first unread message

Florian Heysen

unread,
Jan 8, 2024, 1:34:27 PM1/8/24
to Google Ads API and AdWords API Forum
I'm having rights issues accessing my Google Ads account information via my Google cloud app.

Despite the fact that I have set my application to request Google Ads rights, I have the feeling that it does not request access when connecting to the consent screen. As a result, I can't access the Ads API from my JavaScript application.

I have activated the Google Ads API in the cloud console. I also gave the rights to my application as shown below:

Capture d’écran 2024-01-08 à 19.26.19.png
Here's the Google login screen that doesn't ask for access to my Google Ads information:
SCR-20240108-qyno.png
Here is my NextJS 14 server action in typescript that gives me this error : "Error: 7 PERMISSION_DENIED: Request had insufficient authentication scopes."

"use server";

import { User, Account } from "@prisma/client";
import { GoogleAdsApi } from "google-ads-api";

type UserWithAccounts = User & { accounts: Account[] };

export const getCustomers = async (user: UserWithAccounts) => {
const google = user.accounts.filter(
(account) => account.provider === "google"
);

const client = new GoogleAdsApi({
client_secret: "XXXXX-xxxxxxxx",
developer_token: "xxxxxxxxxxx",
});

const refreshToken = google[0].refresh_token;

if (!refreshToken) return { error: "Refresh token does not exist" };

const customer = client.Customer({
customer_id: "0000000000",
refresh_token: refreshToken,
});

const campaigns = await customer.query(`
SELECT
campaign.bidding_strategy_type,
campaign_budget.amount_micros,
metrics.cost_micros,
metrics.clicks,
metrics.impressions,
metrics.all_conversions
FROM
campaign
WHERE
campaign.status = "ENABLED"
LIMIT 20
`);

return campaigns;
};

Google Ads API Forum Advisor

unread,
Jan 8, 2024, 3:55:42 PM1/8/24
to heysen....@gmail.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 issues and a PERMISSION_DENIED error when accessing Google Ads account information via the Google cloud app. In order to find the root cause of the issue, provide us with the complete API logs in.txt format (request and response with request-id and request header) generated at your end.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby 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 the Reply privately to the author option or a direct private reply to this email. 

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

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages