我正在使用ejabberd API邀请用户访问MUC会议室。我为API设置了OAuth。
我已经使用get_room_occupants测试了oauth并且工作正常。
现在,我正在尝试访问/api/send_direct_invitation
,但根据日志,我无权访问此API
我用命令行生成了oauth
ejabberdctl oauth_issue_token admin@host 31540000 "ejabberd:admin"
我是否需要传递任何额外的权限
Ejabberd版本: 17.11
安装于: ubuntu 16.04
配置数据库: mysql
这是ejabberd.yml
文件
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
我尝试通过命令行运行它并收到此错误
命令:ejabberdctl send_direct_invitation naviteam1519 conference.xxx.yyy.com "" "You need this room!" KESH2FABDE@xxx.yyy.com
错误:
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}]}]
答案 0 :(得分:1)
您没有向我们展示您的ejabberdctl send_direct_invitation
命令和日志。
我敢打赌你没有正确格式化的命令:
来自send_direct_invitation api的应该如下所示:
POST /api/send_direct_invitation
{
"name": "room1",
"service": "muc.example.com",
"password": "",
"reason": "Check this out!",
"users": "user2@localhost:user3@example.com"
}
然后一个例子看起来像这样:
ejabberdctl send_direct_invitation aRoom conference.localhost "" "You need this room!" msg_test1@localhost
至于您的ejabbered.yml
文件。你确定你有:
admin@host
用户?那不应该是admin@localhost
吗?
修改强>
根据评论:OP缺少mod-client-state
配置
mod-client-state配置:
示例配置:
modules:
...
mod_client_state:
queue_chat_states: true
queue_pep: false
queue_presence: true
...