This is the javascript code to get the user consent for the scope and
access token
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google Ads API Authentication</title>
<!-- Include the Google Sign-In and Google API client libraries -->
<script src="https://apis.google.com/js/platform.js" async
defer></script>
<script src="https://apis.google.com/js/api.js"></script>
</head>
<body>
<h1>Google Ads API Authentication</h1>
<div id="google-signin-button"></div>
<script>
const API_KEY = 'GOCSPX-**************';
const CLIENT_ID = '***********.apps.googleusercontent.com';
function handleClientLoad() {
gapi.load('auth2', initGoogleAuth);
}
function initGoogleAuth() {
gapi.auth2.init({
client_id: CLIENT_ID,
apiKey: API_KEY,
scope: 'https://www.googleapis.com/auth/adwords'
}).then(() => {
renderGoogleSignInButton();
});
}
function renderGoogleSignInButton() {
gapi.signin2.render('google-signin-button', {
scope: 'https://www.googleapis.com/auth/adwords',
width: 200,
height: 40,
longtitle: true,
theme: 'dark',
onsuccess: onGoogleSignInSuccess,
onfailure: onGoogleSignInFailure
});
}
function onGoogleSignInSuccess(googleUser) {
const authResponse = googleUser.getAuthResponse();
const accessToken = authResponse.access_token;
fetchGoogleAdsAccounts(accessToken)
}
function onGoogleSignInFailure(error) {
console.error('Google Sign-In failed:', error);
}
function fetchGoogleAdsAccounts(accessToken) {
/* Rest API or function to get the Google ad customer ID */
}
</script>
<!-- Load the Google API client library -->
<script
src="https://apis.google.com/js/api.js?onload=handleClientLoad"></script>
</body>
</html>
In the function `fetchGoogleAdsAccounts` I consume the rest API built in
PHP as mentioned in the earlier email.
Can you please let me know which customer ID you are asking for?
On Thursday, December 14, 2023 at 2:08:19 AM UTC-6 Google Ads API Forum
Advisor wrote:
> Hi,
>
> Thank you for getting back to us.
>
> By reviewing your query, I understand that you are trying to get the
> Google Ad account Id for the customer using the access token. In order to
> investigate further, kindly provide us with the uncropped UI screenshot
> including the customer ID to assist you better on this request.
>
>
> 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.!5004Q02r1Y38:ref"
>
> Thanks,
>
> [image: Google Logo] Google Ads API Team
>
>
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/7a6ac525-5c2c-406b-8188-22ce4bc21133n%40googlegroups.com.