我使用的 API 需要使用几个特定且唯一的参数生成的 JSON Web 令牌。在 Node 中,只需使用
var jwt = require(jsonwebtoken')
即可加载正确的库,但这无法在 Apps 脚本中完成。
有没有一个GAS库可以替代node的jsonwebtoken模块?
您可以使用脚本Class.getIdentityToken(); https://developers.google.com/apps-script/reference/script/script-app#getIdentityToken()
在您的应用程序脚本清单中,您必须添加范围 https://www.googleapis.com/auth/userinfo.email 或 https://www.googleapis.com/auth/userinfo.profile
链接中有更多详细信息
在 Google Apps 脚本服务器端代码只能“需要”来自其他 Google Apps 脚本项目的代码。有关详细信息,请参阅库。
相关问答