I am working on ejabberd API to invite users to MUC room. I have setup OAuth for API.
I have tested oauth with get_room_occupants and its working fine.
Now, I am trying to access /api/send_direct_invitation
, but as per logs, I don't have permission to access this api
I have generated oauth with command line
ejabberdctl oauth_issue_token admin@host 31540000 "ejabberd:admin"
Do I need to pass any extra permissions
Ejabberd Version: 17.11
Installed on: ubuntu 16.04
Configuered DB: mysql
Here is a ejabberd.yml
file
api_permissions:
"console commands":
from:
- ejabberd_ctl
who: all
what: "*"
"admin access":
who:
- access:
- allow:
- user: admin@host
- oauth:
- scope: "ejabberd:admin"
- access:
- allow:
- user: admin@host
what:
- "*"
- "!stop"
- "!start"
"public commands":
who:
- ip: "127.0.0.1/8"
what:
- "status"
- "connected_users_number"
commands_admin_access:
- allow:
- user: "admin@host"
commands:
add_commands:
- status
- registered_users
- register
- unregister
- get_roster
- connected_users
- send_stanza_c2s
- send_stanza
- join_cluster
- send_direct_invitation
oauth_expire: 3600
oauth_access: all
I tried running this via command line and got this error
command: ejabberdctl send_direct_invitation naviteam1519 conference.xxx.yyy.com "" "You need this room!" KESH2FABDE@xxx.yyy.com
error:
Problem 'error {bad_jid,<<"KESH2FABDE@xxx.yyy.com">>}' occurred executing the command.
Stacktrace: [{jid,decode,1,[{file,"src/jid.erl"},{line,138}]},
{mod_muc_admin,'-get_users_to_invite/2-fun-1-',2,
[{file,"src/mod_muc_admin.erl"},{line,840}]},
{lists,filtermap,2,[{file,"lists.erl"},{line,1317}]},
{mod_muc_admin,send_direct_invitation,5,
[{file,"src/mod_muc_admin.erl"},{line,826}]},
{ejabberd_ctl,call_command,4,
[{file,"src/ejabberd_ctl.erl"},{line,352}]},
{ejabberd_ctl,try_call_command,4,
[{file,"src/ejabberd_ctl.erl"},{line,321}]},
{ejabberd_ctl,process2,4,
[{file,"src/ejabberd_ctl.erl"},{line,271}]},
{ejabberd_ctl,process,2,
[{file,"src/ejabberd_ctl.erl"},{line,249}]}]
You did not show us your ejabberdctl send_direct_invitation
command and the logs.
My bet is that you don't have correctly formatted command:
from the send_direct_invitation api it should look like this:
POST /api/send_direct_invitation
{
"name": "room1",
"service": "muc.example.com",
"password": "",
"reason": "Check this out!",
"users": "user2@localhost:user3@example.com"
}
Then an example would look like this:
ejabberdctl send_direct_invitation aRoom conference.localhost "" "You need this room!" msg_test1@localhost
As for your ejabbered.yml
file. Are you sure you have:
admin@host
user? Shouldn't that be for you a admin@localhost
?
Edit
Based on the comment: The OP is missing mod-client-state
configuration
mod-client-state configuration:
Example configuration:
modules:
...
mod_client_state:
queue_chat_states: true
queue_pep: false
queue_presence: true
...