Google ads scripts - response code 403

412 views
Skip to first unread message

Natalia Szczyrba

unread,
Aug 12, 2023, 8:44:04 AM8/12/23
to Google Ads Scripts Forum
Hi there,
I am using this script: https://developers.google.com/google-ads/scripts/docs/solutions/link-checker?hl=en
After the change on the "new script experiment", whenever my script runs it's response code is 403, on the ""old" script experiment" everything was okay.
Our IT department says our security features allow Google indexing robots to check the site.

Best,
Natalia
403.jpg

Nils Rooijmans

unread,
Aug 13, 2023, 5:56:49 AM8/13/23
to Google Ads Scripts Forum
have you checked testeing the urls in your browser and using tools like screaming frog?

A 403 Forbidden response code typically indicates that the server understands the request but refuses to authorize it; it doesn't give access.
If your website is returning a 403 response to the UrlFetchApp service while returning a 200 OK response to your browser, there could be several reasons for this discrepancy.

1. User-Agent Header:
Some servers check the User-Agent header to identify the client making the request.
If the User-Agent header sent by UrlFetchApp is different from a standard browser's, the server might block it. You could try setting the User-Agent header to mimic a common browser in your UrlFetchApp request.
Fix: If the server is configured to block requests from non-browser User-Agent strings, you can modify the User-Agent string in your UrlFetchApp request to mimic a common browser.

2. IP Whitelisting:
Some servers allow requests only from specific IP addresses or ranges.
If the server's configuration is set to allow requests only from certain IPs (like your own), requests from other sources (like Google's servers) might be blocked. The web host is blocking Google in their firewall.
Fix: make sure to whitelist all IP addresses used by UrlFetchApp service. Here's the list of IP addresses https://www.gstatic.com/ipranges/goog.txt

3. Authentication:
If your website requires some form of authentication (like cookies or tokens), the request from UrlFetchApp may lack these credentials, leading to a 403 error.
Fix: Make sure that any required authentication headers or cookies are included in the UrlFetchApp request.

4. Rate Limiting:
If the server has rate limiting in place and UrlFetchApp is making requests too frequently, it might trigger a 403 response.
This might not be an issue with your browser if you're not hitting those rate limits (your browinsg behavior typically will not hit these limits, whereas an automated process will)
Fix: decrease the frequency and volume of the requests to your server, or change the server settings to allow for higher limits.

For more details and fixes, visit the answer on my Google Ads Scripts FAQ:


Hope this helps,

Nils Rooijmans
https://nilsrooijmans.com
See my Google Ads Scripts FAQ to avoid the same mistakes I made: https://nilsrooijmans.com/google-ads-scripts-faq/ 

Google Ads Scripts Forum Advisor

unread,
Aug 14, 2023, 5:55:00 AM8/14/23
to adwords...@googlegroups.com

Hi All,

 

Thank you for reaching out to the Google Ads Scripts Support Team.

 

@Nils - Thank you for providing a detailed explanation to this. We truly appreciate your continued patronage to this community.

 

@Natalia - I would like to inform you that the Link Checker solution makes use of the UrlFetchApp service <https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app> from Apps Scripts which I'm afraid our team is unable to further comment on. I would instead recommend you reach out to the Google Apps Scripts support team as they would be able to provide better insights and they are also the primary support for the said service. You may reach out to them via the links below:

 

This message is in relation to case "ref:_00D1U1174p._5004Q2nrZ7f:ref"

Thanks,
 
Google Logo Google Ads Scripts Team


Nokleby Cecena

unread,
Aug 18, 2023, 9:08:16 AM8/18/23
to Nils Rooijmans via Google Ads Scripts Forum

tnwuXaRfY9

david bitrus

unread,
Aug 18, 2023, 9:08:29 AM8/18/23
to Nils Rooijmans via Google Ads Scripts Forum

ZQM0u8nij7
Reply all
Reply to author
Forward
0 new messages