Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] listAccessibleCustomers function throws an unauthorized_client error #448

Open
klausXR opened this issue Apr 4, 2023 · 4 comments
Labels
bug ⚠️ Something isn't working in the library feature request 💡 New ideas

Comments

@klausXR
Copy link

klausXR commented Apr 4, 2023

When trying to access accessible customers of a given refresh token, if the account is a manager account, google requires the login-customer-id parameter to be passed as described here

https://developers.google.com/google-ads/api/rest/auth#login_customer_id

However, this parameter is hardcoded in the service which has the listAccessibleCustomers in the code to be an empty string.

There should be a way to pass this optionally to that service so that the method works.

When I went through their REST API directly and passed in the parameter, everything worked as expected.

@wcoots wcoots added the bug ⚠️ Something isn't working in the library label Apr 12, 2023
@wcoots
Copy link
Contributor

wcoots commented Apr 12, 2023

@klausXR good find, we will look into this when we get the chance

@wcoots wcoots added the feature request 💡 New ideas label Jun 28, 2023
@bobmoff
Copy link

bobmoff commented Aug 9, 2023

I am not sure how this could ever work, to even get a developer token to access the API, the google ads account HAS to be a manager account.. or am I misunderstanding something?

@jobizzness
Copy link

Had to go around this too:

`export const getGoogleAdAccounts = onCall(async (req) => {
const { data } = req;

try {
    const {tokens} = await getGoogleAdsTokens(data.brand$key);

    // Create an instance of the Google Auth Client
    const oauth2Client = new google.auth.OAuth2(
        process.env.GOOGLE_CLIENT_ID,
        process.env.GOOGLE_CLIENT_SECRET,
        "http://localhost:3000/callback" 
    );
    
    oauth2Client.setCredentials({
        refresh_token: tokens.refresh_token
    });

    // Get the access token
    const accessToken = await oauth2Client.getAccessToken();

    // Make a request to the Google Ads API
    const response = await fetch('https://googleads.googleapis.com/v8/customers', {
        headers: {
            'Authorization': `Bearer ${accessToken.token}`,
            'developer-token': process.env.GOOGLE_ADS_DEVELOPER_TOKEN
        }
    });

    const data = await response.json();
    return data.customers;
     
} catch(error) {
     logger.error(`Failed to get Google Ad accounts: ${error}`);
    throw new Error('Failed to get Google Ad accounts');
}

})
`

@donqq
Copy link

donqq commented Sep 15, 2024

I have the same error. any suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ⚠️ Something isn't working in the library feature request 💡 New ideas
Projects
None yet
Development

No branches or pull requests

5 participants