用JWT交换访问令牌
最近更新: 2025年3月24日
- 适用对象:
- Experience Manager as a Cloud Service
创建对象:
- 初学者
- 中级
- 开发人员
在上一步创建的JWT与Adobe IMS API交换访问令牌,然后该令牌可用于访问AEM as a Cloud Service。 要请求访问令牌,请将包含JWT、client_id、client_secret的POST请求发送到IMS身份验证服务。
以下代码用于为访问令牌生成Exchange JWT
public String getAccessToken() {
String jwtToken = getJWTToken();
GetServiceCredentials getCredentials = new GetServiceCredentials();
System.out.println("Getting Access Token");
try {
HttpClient httpClient = HttpClientBuilder.create().build();
HttpHost authServer = new HttpHost(getCredentials.getIMS_ENDPOINT(), 443, "https");
HttpPost authPostRequest = new HttpPost("/ims/exchange/jwt");
List < NameValuePair > nameValuePairs = new ArrayList < NameValuePair > ();
nameValuePairs.add(new BasicNameValuePair("jwt_token", jwtToken));
nameValuePairs.add(new BasicNameValuePair("client_id", getCredentials.getCLIENT_ID()));
nameValuePairs.add(new BasicNameValuePair("client_secret", getCredentials.getCLIENT_SECRET()));
authPostRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs, Consts.UTF_8));
HttpResponse response;
response = httpClient.execute(authServer, authPostRequest);
StatusLine statusLine = response.getStatusLine();
System.out.println("The status code is " + statusLine.getStatusCode());
HttpEntity result = response.getEntity();
String jsonResponseStr = EntityUtils.toString(result);
System.out.println(jsonResponseStr);
JsonReader jsonReader = new JsonReader(new StringReader(jsonResponseStr));
JsonObject jsonObject = JsonParser.parseReader(jsonReader).getAsJsonObject();
System.out.println("Returning access_token " + jsonObject.get("access_token").getAsString());
return jsonObject.get("access_token").getAsString();
} catch (Exception e) {
System.out.print("Error: " + e.getMessage());
}
return "null";
}
Experience Manager
- 概述
- 播放列表
- AEM as a Cloud Service 简介
- Experience Cloud 集成
- 底层技术
- Edge Delivery Services
- Cloud Manager
- 本地开发环境设置
- 开发
- 调试 AEM
- AEM API
- 内容投放
- 缓存
- 访问 AEM
- 身份验证
- 高级网络
- 安全性
- AEM 事件
- 迁移
- 内容片段
- Forms
- 为 Forms as a Cloud Service 进行开发
- 创建自适应表单
- 使用 Headless 表单的自定义提交服务
- 创建地址区块组件
- 创建可点击的图像组件
- AEM Forms 和 Analytics
- 创建国家/地区下拉组件
- 创建按钮变体
- 使用垂直选项卡
- 使用输出和表单服务
- 在 AEM Forms CS 中生成文档
- 使用表单文档服务 API
- 使用批处理 API 生成文档
- Forms CS 中的 PDF 操作
- 与 Marketo 集成
- 使用 Blob 索引标记存储表单提交数据
- 预填基于核心组件的表单
- Azure 门户存储
- 保存并继续填写表单
- 创建审核工作流程
- Acrobat Sign 与 AEM Forms
- 与 Microsoft Power Automate 集成
- 与 Microsoft Dynamics 集成
- 与 Salesforce 集成
- 将表单提交数据存储到 OneDrive 和 SharePoint
- Asset Compute 可扩展性
- 多步教程
- 专家资源