The Google Scripts documentation does not describe any way to retrieve the client's IP address from a Google Apps Script published as a Web App.
Can that be done?
The Google Scripts documentation does not describe any way to retrieve the client's IP address from a Google Apps Script published as a Web App.
Can that be done?
Client access to published Web Apps is channeled through Google's Proxies, so any attempt to get a client's IP will instead report the proxy's IP.
There are no Service APIs that provide a client's IP, but we can use external javascript libraries through the HTML service.
Here is some demonstration code adapted from How to get client's IP address using javascript only?
Code.gs
getIp.html
Result
In one test, the alert popped up with
216.191.234.70
. Lookup of that IP:That's definitely not my IP address.
Conclusion: No, you can't retrieve a user's public IP address using Google Script.
The following code will return user's ip:
getIp.html
Code.js