AEM Basic authentication in servlet throws 401 | Community
Skip to main content
Level 3
May 24, 2024

AEM Basic authentication in servlet throws 401

  • May 24, 2024
  • 2 replies
  • 1182 views

Hello Team

 

We have an api-account in aem with user name and password.

 

Configured AEM Sling authentication service for HTTP basic authentication

 

We have servelts in AEM which will be called by non-aem projects. While calling the servlet, the client sends Bearer token in request header to authenticate.

 

But when clients calls the request, he receives '401' and no other error/exception message other than 401

 

 

I want to know how and where is the authentication happening in AEM.?

 

And I where can I see complete HTTP request that the client is sending to AEM? Any specific log file in AEM dispatcher? Any logger in AEM instance?( Since it is authentication error client request does not go to servlet to log request details)

 

Any leads on this would really help. Thank you

 

 

 

@aanchal-sikka 

 

@lukasz-m 

 

@joerghoh 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
May 24, 2024

Hi,

If you are using basic authentication you should append the header as below:

Authorization: "Basic" + "base64_encoded_credentials"

The encoding will vary per programming language, for example in java you could do something like this:

String password = "my_password"; String encodedCredentials = Base64.getEncoder().encodeToString(password.getBytes());

 Hope this helps

Esteban Bustamante
Level 3
May 24, 2024

We are already passing the Bearer token in request. In same way as you mentioned. Still it throws 401

h_kataria
Community Advisor
Community Advisor
June 8, 2024

httpdaccess, httpderror and aem request logs should give some idea where the problem lies.
Meanwhile could you share your Sling authentication service config details ?