@adobe/aio-lib-ims-oauth

中文文档
6.1.1发布于 2026/09/22Apache-2.0CommonJS近 30 天下载 4.9万

OAuth2 (SUSI) token creation plugin for @adobe/aio-lib-ims

原始使用文档

OAuth support for Adobe I/O IMS Library

OAuth2 (SUSI) token creation plugin for aio-lib-ims.

Version Downloads/week Node.js CI Codecov Coverage License

This plugin is intended to be used in conjunction with the aio-lib-ims extending that to support browser based 3-legged OAuth2 authentication with IMS commonly known as SUSI flow.

For more information about the general setup of the Adobe I/O CLI IMS Plugin, please refer to aio-lib-ims.

The 3-legged OAuth2 requires interaction with a browser as the initial authentication step to receive the authorization code may be involving multiple browser based steps. For example an IMS Enterprise integration may involve further redirects to a 3rd party for actual authentication.

Workflow:

  1. A 4-byte random pass-code is generated
  2. A localhost web server is created, listening at a port number
  3. An Adobe I/O Runtime web action is opened in the browser, passing in this pass-code, the localhost web server port number, the client id, and the IMS scope as query parameters
  4. The Adobe I/O Runtime web action will redirect to the IMS authorization endpoint, with the scope, client id and a csrf token as the state property (derived from the id, client id, scope and localhost port) passed in as query parameters
  5. When the user is authenticated or an error occurs, the IMS endpoint will redirect to the Adobe I/O Runtime web action's login-success path
  6. If the authentication is successful, the Adobe I/O Runtime web action will redirect to the localhost web server at the specified port (derived from the state property), and forward the state and code properties to the localhost web server call as query parameters
  7. The localhost web server will pass on the authorization code to the library, and the library will call an IMS endpoint to exchange the authorization code for an access token and refresh token
  8. If the authentication is not successful, the Adobe I/O Runtime web action will report an error message in the web browser

The Adobe I/O Runtime function used (currently in testing) is coming soon.

Config

Add the oauth2 context into your .aio file in your current working directory (project folder), under ims:

{
  ims: {
    contexts: {
      oauth2: {
          client_id: "YOUR_CLIENT_ID",
          client_secret: "YOUR_CLIENT_SECRET",
          scope: "YOUR_IMS_SCOPE"
      }
    }
  }
}

The context can be named anything (here oauth2 is chosen for the context name).

Client ID

The Client ID (called the OAuth2 credential in Developer Console) must allow the Adobe I/O Runtime action's login-success path as the redirect URL. To this avail it should be configured as one of the redirect URI patterns of the OAuth2 credential in the Developer Console with the value:

https://aio-login\.adobeioruntime\.net/api/v1/web/default/applogin/login-success

Please note the backslash escaping of the dots in the URLs which is very important because this value must be a valid regular expression.

For example as shown in the following screenshot editing the credential:

Edit Credential

Environment Variables

VariableDescriptionDefault
AIO_IMS_LOCAL_LOGIN_PORTThe port number for the local login server. Useful for Docker environments where a specific port needs to be forwarded. Must be a valid number; falls back to 0 (OS-assigned) if not set or invalid.0

For example, to run aio login inside a Docker container with port forwarding:

export LOCAL_LOGIN_PORT=8080
docker run --rm -it -p ${LOCAL_LOGIN_PORT}:${LOCAL_LOGIN_PORT} -e AIO_IMS_LOCAL_LOGIN_PORT=${LOCAL_LOGIN_PORT} node:24-slim sh -c "npm install -g @adobe/aio-cli && bash"

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.

版本与发布记录

@adobe/aio-lib-ims-oauth 共发布 31 个版本,首次发布于 2020/02/25;过去 12 个月发布了 3 个版本。

版本发布日期距今
6.1.1latest2026/09/221 个月前
6.1.02026/03/247 个月前
6.0.52025/12/0311 个月前
6.0.42025/05/301.4 年前
6.0.32024/12/041.9 年前
6.0.22024/02/122 年前

其他发布通道:next → 5.4.0-pre.2024-01-08.sha-e584fa01。

关于 @adobe/aio-lib-ims-oauth 的常见问题

@adobe/aio-lib-ims-oauth 是什么?

OAuth2 (SUSI) token creation plugin for @adobe/aio-lib-ims

如何安装 @adobe/aio-lib-ims-oauth?

在项目目录运行 npm install @adobe/aio-lib-ims-oauth,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@adobe/aio-lib-ims(^7 || ^8)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@adobe/aio-lib-ims-oauth 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/adobe__aio-lib-ims-oauth 是否存在。

@adobe/aio-lib-ims-oauth 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@adobe/aio-lib-ims-oauth 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adobe/aio-lib-ims-oauth 可以商用吗?

@adobe/aio-lib-ims-oauth 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@adobe/aio-lib-ims-oauth 的下载量有多少?

根据 npm 官方下载统计,@adobe/aio-lib-ims-oauth 在 2026/10/05 – 2026/11/03 这 30 天内被下载 48,830 次,日均约 1,628 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adobe/aio-lib-ims-oauth 还在维护吗?

最新版本 6.1.1 发布于 2026/09/22(1 个月前);至今共发布 31 个版本,其中过去 12 个月发布了 3 个;首次发布于 2020/02/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。