The requested URL returned error: 403
dvnkln opened this issue · comments
Expected behavior
Hello World Example returns the i-doit version
Actual behavior
I'm getting the following error:
PHP Fatal error: Uncaught Exception: The requested URL returned error: 403 in /opt/scripts/vendor/bheisig/idoitapi/src/API.php:512
Stack trace:
#0 /opt/scripts/vendor/bheisig/idoitapi/src/API.php(405): bheisig\idoitapi\API->execute(Array)
#1 /opt/scripts/vendor/bheisig/idoitapi/src/Idoit.php(40): bheisig\idoitapi\API->request('idoit.version')
#2 /opt/scripts/apiclient.php(16): bheisig\idoitapi\Idoit->readVersion()
#3 {main}
thrown in /opt/scripts/vendor/bheisig/idoitapi/src/API.php on line 512
Steps to reproduce the behavior
Try using the provided "Hello, World!" example (change the API variables to your need ofc), mine looks like this:
#!/usr/bin/php
<?php
use bheisig\idoitapi\API;
use bheisig\idoitapi\Idoit;
require_once 'vendor/autoload.php';
$api = new API([
'url' => 'https://_yourserver_/src/jsonrpc.php',
'key' => '_yourapikey_',
'username' => '_yourusername_',
'password' => '_yourpassword_'
]);
$request = new Idoit($api);
$info = $request->readVersion();
var_dump($info);
?>
### Underscored text has been altered
Environment
Question | Answer |
---|---|
bheisig/idoitapi version | 0.4 |
PHP version | 7.0.29 |
i-doit version | 1.10.1 pro |
i-doit API add-on version | 1.9 |
Server logs
Excerpt taken from /var/log/apache2/error.log
:
sadly the log doesn't show anything when executing the script
Excerpt taken from /var/www/html/i-doit/log/api_*.log
:
same here, no information is logged
When i do a "manual" curl api call it works fine with the same api url/key/user.
That's why it shouldn't be a permission problem, right?
Hi,
Thanks for your report 👍
The error message "The requested URL returned error: 403" is directly thrown by the cURL lib. My guess is that something went wrong during authentication. Some more details may help to understand this behavior:
- (Anoymized) screenshot of i-doit Web GUI:
Administration > Interfaces / external data > JSON-RPC API
- Apache access log
- What happens when you use
https://demo.i-doit.com/src/jsonrpc.php
with API keyc1ia5q
instead of your own instance?
Alright here you go
-
Excerpt taken from
/var/log/apache2/access.log
right after executing the script:
...
180.1.24.60 - - [11/Apr/2018:11:32:24 +0200] "GET /idoit/images/icons/silk/comments.png HTTP/1.1" 200 1037 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:24 +0200] "GET /idoit/images/icons/silk/book_open.png HTTP/1.1" 200 1102 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:24 +0200] "GET /idoit/images/empty.gif HTTP/1.1" 200 521 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:24 +0200] "GET /idoit/images/dtree/folder.gif HTTP/1.1" 200 852 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:24 +0200] "POST /idoit/?ajax=1&call=fetch_mandators HTTP/1.1" 200 411 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:24 +0200] "GET /idoit/images/dtree/plus.gif HTTP/1.1" 200 429 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:24 +0200] "GET /idoit/images/dtree/line.gif HTTP/1.1" 200 544 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:48 +0200] "GET /idoit/?moduleID=8&what=api&treeNode=25 HTTP/1.1" 200 17142 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:48 +0200] "POST /idoit/?ajax=1&call=fetch_mandators HTTP/1.1" 200 411 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=api&treeNode=25" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:49 +0200] "POST /idoit/?moduleID=8&what=api&treeNode=25&call=category&ajax=1 HTTP/1.1" 200 3329 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=api&treeNode=25" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:49 +0200] "GET /idoit/?moduleID=8&what=api&treeNode=25&call=category&request=breadcrumb&ajax=1 HTTP/1.1" 200 630 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=api&treeNode=25" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:51 +0200] "POST /idoit/index.php?moduleID=8&what=api&treeNode=25&call=category&ajax=1 HTTP/1.1" 200 2369 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=api&treeNode=25" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:54 +0200] "POST /idoit/?moduleID=8&what=api&treeNode=25&call=category&&ajax=1 HTTP/1.1" 200 2507 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=api&treeNode=25" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:55 +0200] "GET /idoit/?moduleID=8&what=api&treeNode=25&call=category&&request=breadcrumb&ajax=1 HTTP/1.1" 200 630 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=api&treeNode=25" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:11:32:55 +0200] "GET /idoit/index.php?moduleID=8&what=api&treeNode=25&request=breadcrumb&ajax=1 HTTP/1.1" 200 630 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=api&treeNode=25" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:40 +0200] "GET / HTTP/1.1" 200 5760 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:42 +0200] "GET /idoit/ HTTP/1.1" 200 11829 "https://idoit-demo.sv.nr/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:42 +0200] "POST /idoit/?ajax=1&call=fetch_mandators HTTP/1.1" 200 411 "https://idoit-demo.sv.nr/idoit/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:42 +0200] "POST /idoit/?call=dashboard&ajax=1&func=load_widget&hash= HTTP/1.1" 200 6479 "https://idoit-demo.sv.nr/idoit/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:42 +0200] "POST /idoit/?call=dashboard&ajax=1&func=load_widget&hash= HTTP/1.1" 200 7394 "https://idoit-demo.sv.nr/idoit/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:42 +0200] "POST /idoit/?call=dashboard&ajax=1&func=load_widget&hash= HTTP/1.1" 200 152319 "https://idoit-demo.sv.nr/idoit/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:42 +0200] "POST /idoit/?call=dashboard&ajax=1&func=load_widget&hash= HTTP/1.1" 200 6650 "https://idoit-demo.sv.nr/idoit/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:42 +0200] "POST /idoit/?call=dashboard&ajax=1&func=load_widget&hash= HTTP/1.1" 200 17654 "https://idoit-demo.sv.nr/idoit/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:45 +0200] "GET /idoit/?moduleID=8&what=system_settings HTTP/1.1" 200 18288 "https://idoit-demo.sv.nr/idoit/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:07:45 +0200] "POST /idoit/?ajax=1&call=fetch_mandators HTTP/1.1" 200 411 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:08:00 +0200] "GET /idoit/?moduleID=8&what=api&treeNode=25 HTTP/1.1" 200 17142 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=system_settings" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:08:01 +0200] "POST /idoit/?ajax=1&call=fetch_mandators HTTP/1.1" 200 411 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=api&treeNode=25" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
180.1.24.60 - - [11/Apr/2018:12:08:02 +0200] "POST /idoit/?moduleID=8&what=api&treeNode=25&call=category&ajax=1 HTTP/1.1" 200 3329 "https://idoit-demo.sv.nr/idoit/?moduleID=8&what=api&treeNode=25" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
- Mh it works that way. So there has to be some problem with our configuration..
Your access.log looks like there is no single request by your script. My guess is "url" in your config is wrong. Are both your script and i-doit on the same machine? Maybe this machine is unable to resolve your configured hostname. On client side you can use tcpdump
(or something else) to see what's going on.
Aaah my bad. It was a proxy problem after all.
I had to configure a proxy server for composer and forgot to add an exception for the local network range.
It's still not really working. I guess curl kinda ignores the exceptions in /etc/environment
.
I'm looking into it.
All done, it's working now.
Using the right syntax even curl uses the no_proxy variable 👍 .
The value can specify subdomains in presence or absence of the dot (e.g. .example.com or example.com) but can not specify regular expression (e.g. *.example.com).