I've deployed a Let's Chat application for my own server.
However, instead of using currently built, original Let's Chat web application I would like to develop my own, using its API.
And according to Let's Chat wiki:
Revoke an API Token
In the top-left dropdown menu:
- Select "Auth tokens"
- Click "Revoke token"
- Choose "Yes". This will delete any previously generated token.
Basic Authentication
Use the API token as the username when authenticating. The password can be set to anything, but it must not be blank (simply because most clients require it).
So far I've generated own token and tried to send GET
request to retrieve all rooms that I have in the app, but I've got an error: 401 - Unauthorized
- I've tried to send this request with { data: my_token, password: my_random_password }
credentials but without success. So my main question is: how exactly I can authenticate with Let's Chat API using ajax request?
I couldn't find any API url / endpoint dedicated for such task - please help.
EDIT:
I've tried also setting headers but it still doesn't work:
$.ajax({
url: CHAT_URL + 'rooms',
beforeSend: function(xhr){
xhr.setRequestHeader('username', 'NTczYzZ1111111111111111111JiMWE3MGUwYThiNzZhYjhmYjFjOWJkOTQ5ZDQ2YjhjNWUyMzkwNmMzYjhjMQ==');
xhr.setRequestHeader('password', '123qwe');
}
}).done(function(resp){
console.log('1');
console.log(resp);
}).done(function(resp){
console.log('2');
console.log(resp);
});