Skip to content

adobe/aio-lib-core-auth

Version Downloads/week Node.js CI License Codecov Coverage Size(minified)

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-auth

Usage

Generating an Access Token in a Runtime action

const { 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.

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.

About

Auth module for use by the Adobe I/O SDK

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •