Search code examples
oauthejabberd

Getting 'access_denied' when trying to get oauth token for ejabberd, to call REST API


My main intention is to save users, shared_rosters, add users to shared_rosters etc... from my website. I am using NodeJS for the backend.

I couldnt really find any library to do the above mentioned tasks, hence I decided to use the REST API with JSON, available with ejabberd(please share any libraries that can do the above mentioned tasks). For this, I am trying to get an access token through oauth for ejabberd. I have followed the steps mentioned in the ejabberd docs.

I have added the following to my 'ejabberd.yml' file.

-
port: 5280
module: ejabberd_http
request_handlers:
  "/websocket": ejabberd_http_ws
  "/log": mod_log_http
  # OAuth support:
  "/oauth": ejabberd_oauth
  # ReST API:
  "/api": mod_http_api
web_admin: true
http_bind: true
captcha: true

Also added the oauth specific parameters in the yml file.

commands_admin_access: configure
commands:
  - add_commands: user
oauth_expire: 3600
oauth_access: all

I am not sure if the placement of the oauth parameters is very important. I was not sure where to place it, so I placed it above the following line. I saw this placement on some other page.

### DATABASE SETUP

Restarted Ejabberd.

When i go to the following URL, I get the expected page

http://example.net:5280/oauth/authorization_token?response_type=token&client_id=Client1&redirect_uri=http://client.uri&scope=get_roster+sasl_auth

Now, when i put in my admin's username and password, as below

User: admin@xxx.xxx.x.xxx
Server: xxx.xxx.x.xxx
Password: admin

I get the response as

error=access_denied

I am not sure what I am missing. Can anyone please help me out here?


Solution

  • I was also doing the same thing, actually, when I entered data as

    User: admin Server: xxx.xxx.x.xxx Password: admin

    I was able to get the token.