I am trying to hit URL in cq Author instance from my standalone code.
URL looks like - http://<somehost>:<someport>//libs/dam/gui/content/reports/export.json
Below is the code -
URL url = new URL(newPath);
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.setRequestMethod("GET");
connection.setReadTimeout(15 * 10000);
connection.connect();
reader = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
stringBuilder = new StringBuilder();
But I got error 401 which is expected as I'm not passing any authentication information. hence Sling says that "getAnonymousResolver: Anonymous access not allowed by configuration - requesting credentials"
Please advice how to proceed on this.
Solved! Go to Solution.
Views
Replies
Total Likes
Add the below code -
Views
Replies
Total Likes
Add the below code -
Views
Replies
Total Likes
As per the slingAuthentication logic it doesn't allow aonymous login, try setting username and password.
https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.auth.core-1.1.0/src/main/java/org/apach... // If we get here, anonymous access is not allowed: redirect // to the login servlet log.info("getAnonymousResolver: Anonymous access not allowed by configuration - requesting credentials"); doLogin(request, response);
Views
Replies
Total Likes
You can also code a Sling Servlet so that authentication is not required by using a Property annotation.
@Property(name = "sling.auth.requirements", value = "-/bin/upfile")
http://helpx.adobe.com/experience-manager/using/post_files.html
Note this this article:
Although this development shows you how to configure a Sling Servlet so that authentication is not required, it is strongly recommended that you use this only when required. There are some use cases for this. For example, when you need to create a Sling Servlet that collects data from anonymous users. In most use cases, it is strongly recommended that you code your Sling Servlets so that authentication is required.
Views
Replies
Total Likes
By default Sling supports basic authentication.
Kind regards,
Jörg
Views
Replies
Total Likes
Hi,
This works, but it would be significantly easier to user a higher-level HTTP client API which supports basic authentication.
Justin
Views
Replies
Total Likes
justin_at_adobe wrote...
Hi,
This works, but it would be significantly easier to user a higher-level HTTP client API which supports basic authentication.
Justin
Thanks Justin, will keep eye on it
Views
Replies
Total Likes
Views
Like
Replies
Views
Likes
Replies