For XML/JSON, follow steps below:
You can authenticate like this:
api.do?function=login&username=[username]&password=[password]&company-code=[company code]
If data format is XML and your authentication is successful, you will receive XML with two elements: token and user_id. For example:
<result><token>ae48ef19bcfd1</token><user_id>12918</user_id></result>
In case the data format is JSON, you will receive an object with properties token and user_id respectively. On how to handle errors, see Error Handling and Debugging