You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取当前临时匿名活跃用户密钥及相关存储与比对方法?

Session.getTemporaryActiveUserKey() Anonymous Key Details

Let’s tackle your questions about the anonymous user key returned by Session.getTemporaryActiveUserKey() when no user is logged in:

1. Storage Location of the Anonymous User Key

The anonymous temporary key is managed entirely by Google’s Apps Script session infrastructure. It’s stored server-side, tied to the anonymous session context, and there’s no exposed, accessible storage location that your script can directly read or modify.

On the client side, Google may use session cookies to track this anonymous context, but these are handled automatically by the browser and aren’t accessible to Apps Script code—since scripts run server-side, they don’t have direct access to client-side cookie data.

2. Retrieving the Current Anonymous Key for Comparison

Good news: You don’t need a separate method to get the current anonymous key—calling Session.getTemporaryActiveUserKey() itself in an anonymous session will return the active anonymous key.

Here’s how you can use this for comparison:

  • When you need to check if the current session is anonymous and verify the key, simply invoke the method. If no user is logged in, it will return the current valid anonymous key (which rotates every 30 days automatically, as noted in the docs).
  • To compare against a previously stored anonymous key, save the key value (e.g., in PropertiesService) and then compare it to the value returned by a fresh call to Session.getTemporaryActiveUserKey().

Keep in mind that if the key has rotated (after 30 days), the new call will return the updated key, so your comparison will naturally detect the change.

内容的提问来源于stack exchange,提问作者Alberto Balistreri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:49:50