getActiveUser() 没有 return 用户?
getActiveUser() doesn't return the user?
我刚刚第一次将插件发布到 G Suite Marketplace :D
(大约 2 周后,Google 今天发布了我们的插件)
我注意到的第一件事是:很多错误 :(
虽然我已经非常仔细地用绑定文档测试了我的代码。
与这行代码相关的错误:
Session.getActiveUser().getEmail()
它总是 returns 一个空字符串,尽管我有 https://www.googleapis.com/auth/userinfo.email
的 OAuth 权限
我想(但不能确定)我需要改用这个函数:
Session.getEffectiveUser().getEmail()
我不能确定,因为我已经更新了代码并向 G Suite Marketplace 提交了一个新版本,但是 Google 还没有发布它(可能是因为从 Addon Store 迁移到 G Suite Marketplace仍然不稳定)
那么您是否有过使用 Addon on G Suite Marketplace 解决此问题的经验?
我应该一直使用 getEffectiveUser()
而不是 getActiveUser()
吗?
编辑:
这是运行代码的上下文 Session.getActiveUser():
- 用户接受 OAuth 权限后
- 边栏出现了
- 客户端代码使用
google.script.run.functionX...
调用函数 X(调用 Session.getActveUser())
According to this guide
https://developers.google.com/gsuite/add-ons/concepts/editor-auth-lifecycle#authorization_modes,
when using google.script.run, the AuthMode is FULL
正如我们在 getActiveUser()
documentation, you will get a blank string if you can't access the user information. Since the AuthMode
can change automatically in some situations (as detailed on the authorization modes documentation 上看到的那样,我们建议记录它以检查它是否处于 AuthMode.FULL
或任何其他模式。我们希望这对您有用。请不要犹豫,向我们提供更多信息以获得进一步的帮助。
我刚刚第一次将插件发布到 G Suite Marketplace :D
(大约 2 周后,Google 今天发布了我们的插件)
我注意到的第一件事是:很多错误 :(
虽然我已经非常仔细地用绑定文档测试了我的代码。
与这行代码相关的错误:
Session.getActiveUser().getEmail()
它总是 returns 一个空字符串,尽管我有 https://www.googleapis.com/auth/userinfo.email
我想(但不能确定)我需要改用这个函数:
Session.getEffectiveUser().getEmail()
我不能确定,因为我已经更新了代码并向 G Suite Marketplace 提交了一个新版本,但是 Google 还没有发布它(可能是因为从 Addon Store 迁移到 G Suite Marketplace仍然不稳定)
那么您是否有过使用 Addon on G Suite Marketplace 解决此问题的经验?
我应该一直使用 getEffectiveUser()
而不是 getActiveUser()
吗?
编辑:
这是运行代码的上下文 Session.getActiveUser():
- 用户接受 OAuth 权限后
- 边栏出现了
- 客户端代码使用
google.script.run.functionX...
调用函数 X(调用 Session.getActveUser())
According to this guide https://developers.google.com/gsuite/add-ons/concepts/editor-auth-lifecycle#authorization_modes, when using google.script.run, the AuthMode is FULL
正如我们在 getActiveUser()
documentation, you will get a blank string if you can't access the user information. Since the AuthMode
can change automatically in some situations (as detailed on the authorization modes documentation 上看到的那样,我们建议记录它以检查它是否处于 AuthMode.FULL
或任何其他模式。我们希望这对您有用。请不要犹豫,向我们提供更多信息以获得进一步的帮助。