cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get token for alfresco authorization

hilal
Confirmed Champ
Confirmed Champ

I use community edition and ı want to try alfresco rest api on postman. But ı get 401 unauthorize message while trying rest api. I think, it wants a token . But  ı dont know how can ı token locally. Thanks.

1 ACCEPTED ANSWER

edcearl
Champ in-the-making
Champ in-the-making

In postman: (note that I am using Alfresco CE 201702, but this should work back to 5.0)

Set the URL to http(s)://hostSmiley Tongueort/alfresco/api/-default-/public/authentication/versions/1/tickets 

Leave the Authorization tab blank

In the 'Body' tab, change the data type to 'raw' and select JSON (application/json) from the dropdown

In the body enter:

{
"userId": "yourusernamehere",
"password": "passwordinplaintext"
}

Hit send.. 

I should note that I am not using the tickets feature in my REST API calls. I am adding basic auth headers to all requests. If you want to go that route just enter your username/password in the Authorization table and click Update Request. That will add a new header to the HTTP request containing your username/password.  

Finally, the API-explorer add-on is wonderful. I deployed it on my test server and you can try out all the REST APIs without having to use Postman. You have to build it yourself, but it is IMHO worth the time to do. 

GitHub - Alfresco/rest-api-explorer: Public REST API Explorer 

View answer in original post

2 REPLIES 2

edcearl
Champ in-the-making
Champ in-the-making

In postman: (note that I am using Alfresco CE 201702, but this should work back to 5.0)

Set the URL to http(s)://hostSmiley Tongueort/alfresco/api/-default-/public/authentication/versions/1/tickets 

Leave the Authorization tab blank

In the 'Body' tab, change the data type to 'raw' and select JSON (application/json) from the dropdown

In the body enter:

{
"userId": "yourusernamehere",
"password": "passwordinplaintext"
}

Hit send.. 

I should note that I am not using the tickets feature in my REST API calls. I am adding basic auth headers to all requests. If you want to go that route just enter your username/password in the Authorization table and click Update Request. That will add a new header to the HTTP request containing your username/password.  

Finally, the API-explorer add-on is wonderful. I deployed it on my test server and you can try out all the REST APIs without having to use Postman. You have to build it yourself, but it is IMHO worth the time to do. 

GitHub - Alfresco/rest-api-explorer: Public REST API Explorer 

hilal
Confirmed Champ
Confirmed Champ

Thank you your answer. It runs successfully. I want to write in detail for help to encounter like my problem.

I pass usernameSmiley Tongueassword(But base64 encoded) Authorization field in header and it works without error.

Thank you again.