To authenticate with the Repository the following URL is used, and it is part of the Authentication API:
http://localhost:8080/alfresco/api/-default-/public/authentication/versions/1/tickets
When calling this URL a HTTP POST should be used with the username and password as data:
$ curl --header "Content-Type: application/json" --request POST --data '{"userId":"admin","password":"admin"}' http://localhost:8080/alfresco/api/-default-/public/authentication/versions/1/tickets {"entry": {"id": "TICKET_08eb7e2e2c17964ca51f0f33186cc2fc9d56d593", "userId":"admin" } }
Here I’m logging in as admin with password admin, which is common for local developer/test installations of ACS. But you can use any other username/password combination that represents a user in the Alfresco User database, being it local or linked to LDAP. However, it’s good to use the admin user when you are playing around with the ReST API as you will almost always get a response back as you have full access. You don’t have to worry about the user having the correct permissions to execute the call, having access to the content, etc. A ticket is return inside a JSON object.
We can make the POST call a bit shorter as -H is short for --header and -d for --data. The -request POST part is optional if you use -d, as the -d flag implies a POST request. So the call can also be executed as follows:
$ curl -H "Content-Type: application/json" -d '{"userId":"admin","password":"admin"}' http://localhost:8080/alfresco/api/-default-/public/authentication/versions/1/tickets | jq { "entry": { "id": "TICKET_08eb7e2e2c17964ca51f0f33186cc2fc9d56d593", "userId": "admin" } }
You get the same ticket back if you call the API multiple times.
Windows users
Single quotes around JSON does not work on Windows, use double quotes instead:
curl -H "Content-Type: application/json" -d "{\"userId\":\"admin\",\"password\":\"admin\"}" http://localhost:8080/alfresco/api/-default-/publ