getActiveUser()不返回用户? [英] getActiveUser() doesn't return the user?

查看:212
本文介绍了getActiveUser()不返回用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将附件首次发布到G Suite市场:D

(大约2周后,Google今天发布了我们的插件)

我注意到的第一件事是:很多错误 :(

尽管我已经非常仔细地用绑定文档测试了代码.

与以下代码行相关的错误:

Session.getActiveUser().getEmail()

尽管我具有https://www.googleapis.com/auth/userinfo.email

的OAuth权限,但它始终返回一个空字符串.

我猜(但不能确定)我需要改用此功能:

Session.getEffectiveUser().getEmail()

我不确定,因为我已经更新了代码并向G Suite Marketplace提交了新版本,但是Google尚未发布(也许是因为从Addon Store迁移到G Suite Marketplace仍然很不稳定)

那么您是否有在G Suite Marketplace上使用Addon处理此问题的经验?

我应该一直使用getEffectiveUser()而不是getActiveUser()吗?


这是运行Session.getActiveUser()的代码的上下文:

  • 用户接受OAuth权限后
  • 出现侧边栏
  • 使用google.script.run.functionX...
  • 的客户端代码调用functionX(具有对Session.getActveUser()的调用)

根据本指南 https://developers.google.com/gsuite/附加组件/概念/编辑器身份验证生命周期#authorization_modes , 使用google.script.run时,AuthMode为FULL

解决方案

正如我们在 getActiveUser()文档,如果您无法访问用户信息,则会得到一个空白字符串.由于AuthMode在某些情况下可以自动更改(如https://developers.google.com/gsuite/add-ons/concepts/editor-auth-lifecycle#authorization_modes, when using google.script.run, the AuthMode is FULL

解决方案

As we can read on the 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), we advise to log it to check if it is on AuthMode.FULL or any other mode. We hope that this is useful for you. Please, don't hesitate to offer us more information for further help.

这篇关于getActiveUser()不返回用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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