This library provides core authentication functionality for Adobe I/O SDK libraries and applications.
npm install @adobe/aio-lib-core-authconst { generateAccessToken } = require('@adobe/aio-lib-core-auth')
async function main(params) {
try {
// Note: Will cache for 5 min
const token = await generateAccessToken({
clientId: params.IMS_CLIENT_ID,
clientSecret: params.IMS_CLIENT_SECRET,
orgId: params.IMS_ORG_ID,
scopes: params.IMS_SCOPES,
})
console.log('Authentication successful:', token.access_token)
} catch (error) {
console.error('Authentication failed:', error)
}
}Note: The token is cached in the Runtime's container memory, a single Runtime action can run in multiple containers.
The library caches tokens for 5 minutes to improve performance. If you need to force a refresh:
const { invalidateCache } = require('@adobe/aio-lib-core-auth')
async function main(params) {
try {
invalidateCache()
} catch (error) {
console.error('Authentication failed:', error)
}
}goto API
Contributions are welcomed! Read the Contributing Guide for more information.
This project is licensed under the Apache V2 License. See LICENSE for more information.