Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

AEM Basic authentication in servlet throws 401

Avatar

Level 4

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 

 

@Jörg_Hoh 

 

3 Replies

Avatar

Community Advisor

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

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

Avatar

Level 3

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