<li>Send POST request, containing two parameters: <b>userName</b> and <b>password</b>, to the <a href="<%=VirtualPathUtility.ToAbsolute("~/api/portals/section.aspx?section=authentication")%>">api/2.0/authentication</a> address
<div class="note">Please note, that you have to enter your own portal address to the <em>Host: yourportal.onlyoffice.com</em> line instead of yourportal.onlyoffice.com address.</div>
<div class="header-gray">Response</div>
<pre>
HTTP/1.1 201 Created
Cache-Control: private
Content-Type: application/json; charset=utf-8
{
"count": 1,
"response": {
"expires": "2010-07-07T17:06:03.5845502+03:00",
"token": "sdjhfskjdhkqy739459234"
},
"status": 0,
"statusCode": 201
}
</pre>
</li>
<li>In case authentication is successful, a token which will look like <b>sdjhfskjdhkqy739459234</b> will be received</li>
<li>Use this token every time you call API methods inserting it to the HTTP Header: Authorization
<div class="header-gray">Sample API Request</div>
<pre>
GET api/2.0/people/@self.json HTTP/1.1
Host: yourportal.onlyoffice.com
Accept: application/json
Authorization:sdjhfskjdhkqy739459234
</pre>
<div class="note">Please note, that you have to enter your own portal address to the <em>Host: yourportal.onlyoffice.com</em> line instead of yourportal.onlyoffice.com address.</div>
var request = System.Net.WebRequest.Create("https://yourportal.onlyoffice.com/api/2.0/authentication.json");
request.Method = "POST";
request.ContentType = "application/json";
var body = "{\"userName\":\"yourusername\",\"password\":\"yourpassword\"}";
var data = System.Text.Encoding.UTF8.GetBytes(body);
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (System.Net.HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
</pre>
<div class="note">Please note, that you have to enter your own portal address to the <em>yourportal.onlyoffice.com</em> line instead of yourportal.onlyoffice.com address.</div>
curl --request POST --header "Content-Type: application/json" --data "{\"username\":\"yourusername\",\"password\":\"yourpassword\"}" "https://yourportal.onlyoffice.com/api/2.0/authentication.json"
</pre>
<div class="note">Please note, that you have to enter your own portal address to the <em>yourportal.onlyoffice.com</em> line instead of yourportal.onlyoffice.com address.</div>