nuket / google-sheets-geocoding-macro

Geocode from addresses to latitude / longitude, and vice versa using Google Sheets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authentication to increase rate limit

zachewente opened this issue · comments

Is there a way to authenticate this script with an API key to increase the daily rate limit? Thanks in advance

In case you didn't find a way to do it, yes, there is.

The Maps object has a setAuthentication method which lets you provide an API key:
https://developers.google.com/apps-script/reference/maps/maps#setAuthentication(String,String)

It would be possible to apply this key by making a call like:
Maps.setAuthentication(clientId, signingKey)

Somewhere near the following lines (or actually I suppose anywhere in the script):
https://github.com/nuket/google-sheets-geocoding-macro/blob/master/Code.gs#L345
https://github.com/nuket/google-sheets-geocoding-macro/blob/master/Code.gs#L400

It's a static method, so I suppose it works for any requests that happen after it is called.

I don't have a Maps API for Business account, but this would be the easiest way to leverage higher quota allowances.