0

Im writing up a google sheets script/add on that writes data to a google mysql database on the google cloud platform. This works perfectly well when I am logged in under my user profile at my google domain However when I run the script as another user (its a google sheet add-on) in my domain user I get the error: Failed to establish a database connection. Check connection string, username and password. The string,username,password are correct because this works fine under my user profile. The script has been deployed to my entire domain and all users have access to it in google sheets under the 'add-ons' menu. I am able to access mysql database using desktop tools from any workstation as long as i whitelist the IP in the google cloud console So I am perplexed as to why the connection is allowed form one user (developer) but no other users in the domain. The line of script is simple: Jdbc.getCloudSqlConnection('jdbc:google:mysql://','',''); I suspect somewhere in the many settings on the SQL part of the cloud console, or in my project I need to enable some sort of scope? Any help would be appreciated

1 Answers1

0

ok, sort of found an answer here: Jdbc connection error from Google Apps Script the end of the post suggests: open IAM. and add the account as a member and add this permission: "Cloud SQL Client". So I opened my cloud console, added the other user XXXX@mydomain.com into the list of users and gave them a 'cloud sql client' role The script then worked in their google sheets. So Im guessing that for all the users in my domain this is not ideal and would have to revert to getConnection function instead. The google documentation very sketchy here because they cite the getCloudSqlConnection as the 'preferred' method.