Может кто подскажет, что я делаю не так?
Захожу на сервере в Описание веб-сервиса доступа к данным с архитектурой REST
Заполняю веб форму для POST /auth/v2/token
Запрос:
curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'username=admin&password=******&grant_type=******' 'http://***.*******.com:8080/auth/v2/token'
Все отлично, ответ:
{
"access_token": "XNtS449TWx_o4aRx0J....",
"token_type": "bearer",
"expires_in": 2591999,
"userName": "Администратор",
"isAdmin": "true",
"permissions": "["EditReportGeneratingTask","Activation","EditPlugins","EditSystemParameters","CloseUserSession","ViewAccountLog","ViewUserSessionLog","ViewMessageLog","GetUserSessionList","ViewSystemLog","ViewLogFiles","EditAnnouncement","EditOwnNotificationSettings","EditAccount","BackupDatabase","InstallSystemUpdate","ContractAnalysis","TemperatureChart","ViewDeviceEvents","ViewDeviceConfig","ViewData","SaveData","ExportToXml80020","ViewMap","CloseIncident","ViewIncident","DeleteIncident","CallGprsController","PollCurrents","DisconnectGprsController","ViewPollSession","ViewControllersStatistics","ViewGsmStatistics","AllowAnyPollPort","ForceStopPoll","ManualPoll","RemoteConsole","PollQueueControl","ViewPreparedReport","PrintReport","EditReportTemplate","EditReport","DeletePreparedReport","HouseBalance","TenantOffice","EditRoom","ManualInputCounterTotals","HouseSummary","DeleteRoom","SendMessage","ControlMessageQueue","MoveMeasurePoint","BrowseNonPublicNodeFile","EditBalanceGroup","EditNodeGroup","EditInspector","EditMap","EditEquipmentModel","EditEquipment","EditServiceman","EditServiceCompany","EditNode","EditCustomer","EditNodeJob","EditServicingStatuses","EditNodeJobResolution","EditSupplier","EditPollPort","EditOutdoorTemperature","EditTerritory","EditMeasurePoint","DeleteNode","DeleteMeasurePoint","DeleteEquipment"]",
"tenantOfficeOnly": "false",
".issued": "Wed, 04 Dec 2019 11:21:53 GMT",
".expires": "Fri, 03 Jan 2020 11:21:53 GMT"
}
Пытаюсь реализовать это через PHP:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://***.******.com:8080/auth/v2/token");
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0");
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, array("username" => *****, "password" => ******, "grant_type" => "password"));
curl_setopt($curl, CURLOPT_HTTPHEADER, array('POST', '/auth/v2 HTTP/1.1', 'Content-Type: application/x-www-form-urlencoded', 'Accept: application/json; charset=UTF-8'));
$out = curl_exec($curl);
curl_close($curl);
return json_decode($out, true);
Ответ всегда один:
{"error":"unsupported_grant_type"}