0

Hello guys I am using ejabberd and I want to generate a bearer token to access all the methods and to get the data using the REST of ejabberd. When I try to generate the bearer token with no auth in header it shows an error which is enter image description here

i am using the port which is 5180 for the ejabberd_http module my configuration is

    port: 5180
    ip: "::"
    module: ejabberd_http
    request_handlers:
      /admin: ejabberd_web_admin
      /api: mod_http_api
      /xmlrpc: ejabberd_xmlrpc
      /oauth": ejabberd_oauth

and the configurations of api permission is

oauth_access:
  - allow:
    - user:
      - "admin@localhost"  # add your user name

oauth_expire: 86400


acl:
  local:
    user_regexp: ""
  loopback:
    ip:
      - 127.0.0.0/8
      - ::1/128
      - ::FFFF:127.0.0.1/128
      - ::FFFF:43.250.158.125/16
  admin:
    user:
      - "admin@localhost"
    ip:
      - "::"
      - ::FFFF:43.250.158.125/16

api_permissions:
  "some XMLRPC commands":
    from: ejabberd_xmlrpc
    who:
      - ip:  127.0.0.1
      - user: admin@localhost
    what:
      - "*"
      # - registered_users
      # - register
      # - connected_users_number
      # - change_password
      # - check_password_hash

  "admin access":
    who:
      ip: 127.0.0.1/8
      oauth:
        scope: "ejabberd:admin"
        access:
          allow:
            acl: loopback
            acl: admin
    what:
      - "*"

  "console commands":
    from:
      - ejabberd_ctl
    who: all
    what: "*"


  "loopback access":
    who:
      - ip: "::"
    what:
      - "*"


  "public commands":
    who:
      ip: 127.0.0.1/8
    what:
      - "*"




access_rules:
  register:
    allow: all
  # configure: 
  #   - allow: all

  local:
    # allow
    allow: all
  c2s:
    # deny: blocked
    allow: all
  announce:
    allow: all
  configure:
    allow: all
  muc_create:
    allow: all
  pubsub_createnode:
    allow: local
  trusted_network:
    allow: all

i want to send the message to user using the rest but for this i need bearer token , when i try to generate bearer token is shows error plese suggest me some way to fix this issue and to generate the bearer token

thanks

1 Answers1

0

Once this is configured:

oauth_expire: 3600
oauth_access:
  - allow:
    - user:
      - "admin@localhost"  # add your user name

Try first with the command line:

❯ ejabberdctl oauth_issue_token admin@localhost 3600 "registered_users;muc_online_rooms"
yamdcY4TGqltWCprCnunZjrz7ZNSmL8d        [<<"registered_users">>,<<"muc_online_rooms">>] 3600 seconds

Once that works, you can try to obtain the token using the web, which requires more configuration steps.

Badlop
  • 3,840
  • 1
  • 8
  • 9