Can't get Jdbc.getCloudSqlConnection() to work in Google Sheets

183 views
Skip to first unread message

Wing Poon

unread,
Aug 11, 2022, 3:20:00 PM8/11/22
to Google Apps Script Community
I wrote a custom function and when I use Jdbc.getConnection(), it works fine. But when I use Google "recommended" Jdbc.getCloudSqlConnection() instead -- because I want to remove the horrendously long (!)  list of IP ranges that using the former method requires that I whitelist on my Cloud SQL MySQL instance -- it always fails with a "#ERROR! Exception: You do not have permission to call Jdbc.getCloudSqlConnection. Required permissions: https://www.googleapis.com/auth/sqlservice"

I checked in the App Script Editor Overview that I do have the following "Requested":

When I go to the URL "https://www.googleapis.com/auth/sqlservice" in my browser, it returns an unhelpful message stating that "your input OAuth2 scope name is invalid or it refers to a newer scope that is outside the domain of this legacy API". Uhm, which is the "legacy API", the Jdbc.getCloudSqlConnection() (that Google's docs recommends) ....?

That same URL response recommends I go to "https://developers.google.com/identity/protocols/oauth2/scope" to "lookup (manually) the scope name associated with the API you are trying to call". So I went there but there is nothing in there concerning Cloud SQL, SQL or JDBC. I even tried adding:

Searched on S/O and on this forum, but nothing suggested works ... Anybody has any further ideas?

Thanks!
-Wing

Reply all
Reply to author
Forward
0 new messages