@adobe/aio-lib-core-auth
v1.1.0
Published
Adobe I/O Core Authentication Library
Readme
Adobe I/O Core Authentication Library
This library provides core authentication functionality for Adobe I/O SDK libraries and applications.
Installation
npm install @adobe/aio-lib-core-authUsage
Generating an Access Token in a Runtime action
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)
}
}Note: The token is cached for 5 minutes in the Runtime's container memory. A single Runtime action can run in multiple containers, meaning the cache is not shared across actions.
Invalidating the Token Cache in a Runtime action
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)
}
}API
goto API
Contributing
Contributions are welcomed! Read the Contributing Guide for more information.
Licensing
This project is licensed under the Apache V2 License. See LICENSE for more information.
