Solved
author 401 error
Below is my code to servlet
package com.***.core.servlets;
@Component(service = { Servlet.class })
@SlingServletResourceTypes(resourceTypes = "dcp/servlet/assets-locked", methods = HttpConstants.METHOD_GET, extensions = "json")
public class DCPLockedAssetsRequestServlet extends SlingSafeMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {
response.setContentType("application/json");
LOG.info("Forwarding POST request to author instance with Basic Authentication.");
CloseableHttpClient httpClient = HttpClients.createDefault();
// Adapt session and validate user
Session session = request.getResourceResolver().adaptTo(Session.class);
String userId = session.getUserID();
UserManager userManager = request.getResourceResolver().adaptTo(UserManager.class);
Map<String, String> payloadMap = new HashMap<String, String>();
currentUser = userManager.getAuthorizable(userId);
payloadMap.put("assetsPath", assetPath);
payloadMap.put("userId", userId);
payloadMap.put("userPath", currentUser.getPath().toString());
payloadMap.put("principalName", currentUser.getPrincipal().getName());
String authorServiceURL = techCredentialService.getAuthorServletURL();
// Prepare HTTP POST request to author
HttpPost postRequest = new HttpPost(authorServiceURL);
token = dcpUpdateUserService.getToken();
postRequest.setHeader("Authorization", "Bearer " + token);
postRequest.setHeader(***Constants.CONTENT_TYPE, ***Constants.CONTENT_TYPE_JSON);
postRequest.setEntity(new StringEntity(new Gson().toJson(payloadMap)));
// Execute the HTTP request
org.apache.http.HttpResponse authorResponse = httpClient.execute(postRequest);
if (statusCode == 200) {
String responseContent = EntityUtils.toString(authorResponse.getEntity());
JsonObject jsonResponse = new JsonObject();
jsonResponse.addProperty(***Constants.STATUS, "success");
jsonResponse.addProperty(***Constants.MESSAGE, "Workflow triggered successfully.");
response.getWriter().write(jsonResponse.toString());
}}
i am hitting this servlet from publisher,
through this servlet when i hit the author path i.e
https://author-***-***.adobeaemcloud.com/content/api/***/2025.4/locked-assets-author.json
it gives us 401 unauthorised from author
we have used the tech credentials of the techaccount user, through that we are getting access token and providing to it and we have given all the permission to that useron root jcr:All, but its giving 401 then also
Please, ASAP can i get the help??
it gives us 401 unauthorised from author
we have used the tech credentials of the techaccount user, through that we are getting access token and providing to it and we have given all the permission to that useron root jcr:All, but its giving 401 then also
Please, ASAP can i get the help??