Web service authentication
From KnowledgeTree Document Management Made Simple
Contents |
authentication
Before any web service action can be done, the client application must first authenticate with KnowledgeTree. This is done by invoking the login method that will start a new session.
login(username : string, password : string, ip : string) : kt_response
The parameters:
- username of the user that needs to access the repository
- password of the user
- ip is the ip address of the user
The ip address is currently logged for authentication purposes only.
As a response, a kt_response object is returned.
The response should have status_code = 0 and the message field contains a session reference that is used in subsequent requests.
Sample psuedo code:
response = webservice.login('admin','admin', '127.0.0.1')
if response.status_code != 0
raise 'Cannot authenticate. Reason: ' + response.message
end
session = response.message
Implementation notes:
It is not necessary to create a new session before attempting an action. The application should create a session once, store it and reuse the session reference. Sessions do have a lifetime that is configured by the server. If a session expires, a new session will need to be created.
ending a session
The client application can terminate a session by calling the logout method.
logout(session : string) : kt_response
The parameters:
- session is the session returned during the authentication process.
As a response, a kt_response object is returned.
Sample psuedo code:
response = webservice.logout('3a598320171890920a6b13f7fcc69dce')
if response.status_code != 0
log 'Problem logging out. Reason: ' + response.message
end
anonymous login
If anonymous access is required, the anonymous_login may be used:
anonymous_login(ip : string) : kt_response
The parameters:
- ip is the ip address of the user.
As a response, a kt_response object is returned.
Sample psuedo code:
response = webservice.anonymous_login('127.0.0.1')
if response.status_code != 0
log 'Problem logging out. Reason: ' + response.message
end
del.icio.us
reddit

