# Obtain authorization token interface

#### Interface Description

Tokens required to access other interfaces must be obtained from this interface through the authorized Appid and Accesskey (except for the batch IVR interface). The timeliness of the interface authorization Token is 12 hours.

#### Request method

POST, form-data format

#### request parameters

<table id="bkmrk-parameter-name-type-"><thead><tr><th align="left">parameter name</th><th align="left">type</th><th align="left">Is it necessary</th><th align="left">illustrate</th></tr></thead><tbody><tr><td align="left">appid</td><td align="left">string</td><td align="left">yes</td><td align="left">authorized appid</td></tr><tr><td align="left">accesskey</td><td align="left">string</td><td align="left">yes</td><td align="left">authorized accesskey</td></tr><tr><td align="left">service</td><td align="left">string</td><td align="left">yes</td><td align="left">App.Sip\_Auth.Login</td></tr></tbody></table>

#### Interface request example（PHP）

```PHP
<?php
    $apiUrl = 'http://127.0.0.1:8080';
    $postFields = [
    'service'    => 'App.Sip_Auth.Login',
    'appid'      => 'ABCDEFG',
    'accesskey'  => 'ABCDEFG',
    ];
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $apiUrl);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl);
    $curlError = curl_error($curl);
    curl_close($curl);
    var_dump($response);
?>


```

#### Return Data Example

```
{
    "ret":200,
    "data":{
        "status":0,
        "desc":"Authorization successful",
        "result":{
            "companycode":"1",
            "companyname":"test",
            "token":"773a70dd02f0695d50205e9b267692b9",
            "authtime":"2020-01-01 00:00:00",
            "authmodel":""
        },
        "reqtime":1581240882,
        "rsptime":1581240882
    },
    "msg":""
}


```

#### Return parameter description

<table id="bkmrk-parameter-name-type--1"><thead><tr><th align="left">parameter name</th><th align="left">type</th><th align="left">illustrate</th></tr></thead><tbody><tr><td align="left">companycode</td><td align="left">int</td><td align="left">Company code</td></tr><tr><td align="left">companyname</td><td align="left">string</td><td align="left">Company Name</td></tr><tr><td align="left">token</td><td align="left">string</td><td align="left">Authorization token, used to access other interfaces</td></tr></tbody></table>