Closed sibithabijesh closed 7 years ago
Please try with this api_permisions:
api_permissions:
"console commands":
from:
- ejabberd_ctl
who: all
what: "*"
"admin access":
who:
- admin
- oauth:
- scope: "ejabberd:admin"
- admin
what:
- "*"
- "!stop"
- "!start"
"oauth sasl_auth":
- who:
- oauth:
- scope: "sasl_auth"
- admin
- what:
- "*"
This will allow access to anyone from acl admin using oauth with token sasl_auth
Will it work with token ?
I am trying to register with below code
<?php
$param_auth=array("user"=>"admin", "host"=>"localhost",'server'=>"localhost", "token"=>"mytoken");
$param_comm=array("user"=>"vishnu", "host"=>"localhost","password"=>"123456");
$param=array($param_auth, $param_comm);
$request = xmlrpc_encode_request('register', $param, (array('encoding' => 'utf-8')));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "User-Agent: XMLRPC::Client mod_xmlrpc\r\n" .
"Content-Type: text/xml\r\n" .
"Content-Length: ".strlen($request),
'content' => $request
),"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
)));
$file = file_get_contents("http://1IP:4560/", false, $context);
echo "<pre/>";print_r($file );
$response = xmlrpc_decode($file);
if (xmlrpc_is_fault($response)) {
trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {
print_r($response);
}
Still getting the same error
Notice: xmlrpc: Error -118 A problem '{error,access_rules_unauthorized}' occurred executing the command register with arguments [{user,<<"vishnu">>},{host,<<"localhost">>},{password,<<"123456">>}] (
I am testing this with newest version of ejabberd and it's seems to be working here, let me check with your version.
ejabbered version is 17.01
I can't register through xmlrpc via token . I have created that token with scope get_roster sasl_auth
when I run the code after changing permission, got below error
Warning: file_get_contents(http://ip:4560/): failed to open stream: HTTP request failed!
but when I run the script for getting connected_users_info, I got below error
Notice: xmlrpc: Error -112 Unknown call: {call,connected_users_info,[{array,[]}]} (-112)
please let me know , can I run all the commands in the API section by using the token with scope et_roster sasl_auth
Ok looks like there was a bug that was fixed after your version, let me prepare fix that you could test.
will it fix it now ?
Is there any limit in creating token via that url. Yesterday I could created the token. But today I got access_denied error
Please download this file, unzip it and replace file with same name in ejabberd installation dir with it: beam.zip
After that restart ejabberd and try it
I think you got that error as a result of that bug (it causes authentication processor to be stopped when it process some rules), so after updating with that beam file you should be good to go.
okay. I willl do that and try again
Thank you very much. it worked :) :) 👍
but still I can't create token via url
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I am trying to use oauth rest api for connecting from external server. I have sucessfully generated token. But when I tried to get connected users, I got the below error.
AccessRules: Account does not have the right to perform the operation error message
Code :- curl_setopt_array($curl, array( CURLOPT_PORT => "5280", CURLOPT_URL => "http://Ip:5280/api/get_roster", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"host\":\"localhost\",\"user\":\"testuser\"}", CURLOPT_HTTPHEADER => array( "Authorization: bearer Token", "cache-control: no-cache", "content-type: application/json", "X-Admin: true" ), ));
My yml file