Google脚本Jdbc.getCloudSqlConnection仅适用于我的域中的一个用户 [英] Google script Jdbc.getCloudSqlConnection only working for one user in my domain

查看:61
本文介绍了Google脚本Jdbc.getCloudSqlConnection仅适用于我的域中的一个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Google表格脚本/添加内容,以将数据写入google cloud平台上的google mysql数据库.当我在我的Google域中的用户个人资料下登录时,此方法非常有效但是,当我以域用户中的另一个用户(其Google工作表加载项)身份运行脚本时,出现错误:无法建立数据库连接.检查连接字符串,用户名和密码.字符串,用户名,密码是正确的,因为在我的用户个人资料下可以正常工作.该脚本已部署到我的整个域,并且所有用户都可以在附加组件"菜单下的Google表格中访问它.我可以在任何工作站上使用桌面工具访问mysql数据库,只要我将Google云控制台中的IP列入白名单因此,对于为什么允许一个用户(开发人员)但域中没有其他用户允许连接,我感到困惑.脚本行很简单:Jdbc.getCloudSqlConnection('jdbc:google:mysql://','','');我怀疑云控制台的SQL部分的许多设置中的某个地方,还是在我的项目中需要启用某种范围?任何帮助将不胜感激

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

推荐答案

好的,在这里找到了答案: Google Apps脚本中的Jdbc连接错误帖子末尾提示:打开IAM.并将该帐户添加为成员并添加以下权限:"Cloud SQL Client".因此,我打开了我的云控制台,将另一个用户XXXX@mydomain.com添加到用户列表中,并赋予了他们云sql客户端"角色然后,脚本在他们的Google表格中运行.因此,我猜测对于我域中的所有用户来说,这都不理想,因此必须恢复为getConnection函数.google文档在这里非常粗略,因为它们将getCloudSqlConnection引用为首选"方法.

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.

这篇关于Google脚本Jdbc.getCloudSqlConnection仅适用于我的域中的一个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆