gpt4 book ai didi

google-apps-script - 在 Google Apps 脚本中获取用户 ID

转载 作者:行者123 更新时间:2023-12-02 00:34:26 28 4
gpt4 key购买 nike

是否可以使用 Session service 在 Google Apps 脚本中获取用户 ID(而不是电子邮件地址)或类似的。

我在 GAS 中没有看到任何对它的引用,但在 GAE 中我能够从 Users API 中获取用户 ID .用户 ID 是唯一标识用户的标识符,即使用户更改了他们的电子邮件地址也是如此。

我希望在 GAS 中使用同样的东西。

最佳答案

Is it possible to obtain the User ID (instead of email address) in Google Apps Script using the Session service or similar?

是的,这是可能的。您可以利用 AdminSDK Directory API which is accessible from App Script via the Admin Directory Advanced Google Service 获取用户 ID .

示例用法:

// NOTE: Admin Directory Advanced Service must be enabled first.

// Get first page of user ids for users in domain
var userIds = AdminDirectory.Users.list({"domain":"www.example.com"}).users.map(function(user) {
return user.id;
});

关于google-apps-script - 在 Google Apps 脚本中获取用户 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50306291/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com