1

I've searched for similar questions here on Stackoverflow but they didn't give an answer.

I make a UrlFetchApp.fetch(url) request to some api service, but the service probably bans this requesting IP. I need to whitelist it. I know there are lots of IPs which google apps use, but for now I need to determine at lease this one which is used for this specific call.

I tried this script to figure out the requests:

function getR(){
  var url = 'https://my.APIENDPOINTURL'
  req = UrlFetchApp.getRequest(url, options)
  Logger.log(req)
  resp = UrlFetchApp.fetch(url, options)
  Logger.log(resp)
}

And it gives me this log:

enter image description here

Why does it show my real IP?

What's going on under the hood? I expected the real IP with UrlFetchApp uses in .getRequests() output. Am I missing something?

Are there any tricks of knowing which IP does UrlFetchApp use? I know that there is no this functionality as a native function.

Andrew Anderson
  • 1,044
  • 3
  • 17
  • 26
  • 1
    Does this answer your question? [Determining the IP address of the node that executes the UrlFetchApp call](https://stackoverflow.com/questions/11708477/determining-the-ip-address-of-the-node-that-executes-the-urlfetchapp-call) – Iamblichus Apr 05 '21 at 08:55
  • No, it doesn't. Because, it reads "it's impossible" and just a list of possible IP addresses is given. This information is only related to my question. – Andrew Anderson Apr 07 '21 at 10:25
  • Isn't `it's impossible` an answer? – Iamblichus Apr 07 '21 at 10:39
  • That's just an opinion of one member of a community. People make mistakes often. Also, I have a question in this post why my real IP is shown. – Andrew Anderson Apr 08 '21 at 13:23

1 Answers1

4

You can find a list of IP addresses that Apps Script may use while calling other services here - https://www.gstatic.com/ipranges/goog.txt

It's buried in this JDBC article.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Sourabh Choraria
  • 2,255
  • 25
  • 64
  • "buried" - exactly :). Thank you for that list. It was mentioned in some answers but sicne a lot of time has passed, this list is not somewhere in the article on visible place. However, I would like to know somehow the exact IP being used by UrlFetchApp when doing a request to an external resource. – Andrew Anderson Apr 03 '21 at 09:07