1

我在 Windows 10 (localhost) 上使用 ejabberd-18.01。我正在尝试使用 web 方法通过Postman连接到 ejabberd:

POST:本地主机:5280/api/specific_api_method

根据官方 API 文档(https://docs.ejabberd.im/developer/ejabberd-api/admin-api/),我正在尝试使用 POST 方法添加一个名册项目,正文如下:

POST:本地主机:5280/api/add_rosteritem

{ "localuser": "user1", "localserver": "mydomain", "user": "admin", "server": "mydomain", "nick": "u1", "group": "Friends", "subs": "both" }

我收到一个错误:

{ "status": "error", "code": 32, "message": "AccessRules: Account does not have the right to perform the operation." }

如果有人可以指导我如何验证自己并使用 Web API 将新用​​户或名册项目添加到 ejabberd,我将不胜感激。谢谢。

4

1 回答 1

1

在您的 yml 文件配置文件中进行这些更改

将 acl 中的环回更改为:

loopback:
    ip:
      - "127.0.0.0/8"
      - "::1/128"
      - "::FFFF:127.0.0.1/128"

并使用此 api_permissions:

api_permissions:
  "console commands":
    from:
      - ejabberd_ctl
    who: all
    what: "*"
  "admin access":
    who:
      - access:
          - allow:
            - ip: "127.0.0.1/8"
            - acl: admin
      - oauth:
        - scope: "ejabberd:admin"
        - access:
          - allow:
              - ip: "127.0.0.1/8"
              - acl: admin
    what:
      - "*"
      - "!stop"
      - "!start"
  "public commands":
    who:
      - acl: loopback
    what:
      - "status"
      - "register"
      - "connected_users_number"

此问题已在以下位置关闭:ejabberd 上的访问被拒绝问题

于 2018-10-10T13:37:56.963 回答