Adobe I/O 核心认证库
这个库为Adobe I/O SDK库和应用提供核心认证功能.
安装
npm install @adobe/aio-lib-core-auth
使用量
在运行时动作中生成 Access Token
const { generateAccessToken } = require('@adobe/aio-lib-core-auth')
async function main(params) {
try {
// if the include-ims-credentials annotation is set, the library infers credentials from the Runtime params
const token = await generateAccessToken(params)
// otherwise credentials can be passed manually
const token = await generateAccessToken({
clientId: '<clientId>',
clientSecret: '<clientSecret>',
orgId: '<orgId>@AdobeOrg',
scopes: ['<scope1>', '<scope2>', '..']
})
console.log('Authentication successful:', token.access_token)
} catch (error) {
console.error('Authentication failed:', error)
}
}
注:该令牌被缓存5分钟于"跑步时段"的容器内存. 一个单一的运行时动作可以在多个容器中运行,这意味着缓存不是在动作之间共享的.
在运行时动作中无效保存缓存
图书馆缓存了5分钟的道具来提高性能. 如果您需要强制刷新:
const { invalidateCache } = require('@adobe/aio-lib-core-auth')
async function main(params) {
try {
invalidateCache()
} catch (error) {
console.error('Authentication failed:', error)
}
}
API 密码
goto API 密码
捐款
欢迎捐款! 读取 贡献指南 更多信息.
许可证发放
这个项目根据Apache V2许可证获得许可. 见 自由主义 更多信息.