Search code examples
ejabberdejabberd-auth

Ejabberd oauth is not generating token


Can some please explain me how to configure ejabberd rest api support, I could not find any sufficient resource regarding this.

I'm using linux (ubuntu 16.04), so till now I've done apt-get -y install ejabberd and please tell me is there any need to change in config file /etc/ejabberd/ejabberd.yml file.

<pre>


listen:
  ## To handle ejabberd commands using XML-RPC
  -
    port: 4560
    module: ejabberd_xmlrpc
    access_commands: {}
  -
    port: 5280
 ##   ip: "::"
    ip: "0.0.0.0"
    module: ejabberd_http
    request_handlers:
      "/websocket": ejabberd_http_ws
      # OAuth support:
      "/oauth": ejabberd_oauth
      # ReST API:
      "/api": mod_http_api
    ##  "/pub/archive": mod_http_fileserver
    web_admin: true
    http_bind: true
    register: true
    captcha: true
    tls: false
    certfile: "/etc/ejabberd/ejabberd.pem"

# Allow OAuth authentication and token generation
commands_admin_access: configure
commands:
  - add_commands: [user, admin, open]
# Tokens are valid for a year as default:
oauth_expire: 31536000
oauth_access: all
api_permissions:
  - "admin access":
    - who:
      - admin
    - what:
      - "*"
      - "!stop"

    
    
    
</pre>    

well, I tried as given in the doc, but when I entered the user, server and password at http://ipaddress:5280/oauth/authorization_token?response_type=token&client_id=localhost&redirect_uri=http://www.razrcorp.com/&scope=get_roster+sasl_auth

i can see Authorization request Application localhost wants to access scope get_roster sasl_auth

but when i fill from user - test@localhost server - ipaddress password - test

It redirect to http://ipaddress:5280/oauth/authorization_token with response This page isn’t working ipaddress didn’t send any data. ERR_EMPTY_RESPONSE

If check the logs it says

2018-04-06 11:33:49.136 [error] <0.671.0> CRASH REPORT Process <0.671.0> with 0 neighbours crashed with reason: call to undefined function oauth2:authorize_password({<<"test@localh ost">>,<<"35.18.18.32">>}, <<"localhost">>, <<"http://www.razrcorp.com/">>, [<<"get_roster">>,<<"sasl_auth">>], {password,<<"test">>})


Solution

  • You are missing the oauth2 modules in your installation. It seems the package you are using may be incorrect. Maybe you should try with ProcessOne packages: https://www.process-one.net/en/ejabberd/downloads/

    They should be complete and contains all the required dependencies.