问题描述
我想请求Ejabberd REST Web服务与 / API / connected_users
端点,但该请求总是返回我401未经授权HTTP错误。
I'm trying to request the Ejabberd REST Web Services with the /api/connected_users
endpoint but the request always returns me 401 Unauthorized HTTP errors.
下面是我的OAuth配置。
Here is my OAuth configuration.
-
port: 5280
module: ejabberd_http
request_handlers:
"/websocket": ejabberd_http_ws
# OAuth Support
"/oauth": ejabberd_oauth
# ReST API:
"/api": mod_http_api
web_admin: true
http_bind: true
register: true
captcha: false
...
commands_admin_access: configure
commands:
- add_commands: user
oauth_expire: 3600
oauth_access: all
由于我用下面的URL生成一个OAuth的文档中解释2访问令牌的管理
用户。
<$c$c>http://localhost:5280/oauth/authorization_token?response_type=token&client_id=myclient&redirect_uri=http://localhost:5280&scope=sasl_auth$c$c>
它返回了我的OAuth令牌。
It returns me my OAuth Token.
<$c$c>http://localhost:5280/?access_token=oLn8Hebh051l2PdCM15tSvHrEI25CpBs&token_type=bearer&expires_in=3600&scope=sasl_auth&state=$c$c>
最后,要求 API / connected_users
端点我做以下。
Finally to request the api/connected_users
endpoint I do the following.
卷曲-v -X GET -HX-管理员:真正的-H授权:承载oLn8Hebh051l2PdCM15tSvHrEI25CpBs的http://本地主机:5280 / API / connected_users
但它总是返回我401未授权错误。
But it always returns me 401 Unauthorized errors.
在我的 ejabberd.log
文件我有这个。
In my ejabberd.log
file I have this.
2016-02-09 09:47:12.177 [info] <0.497.0>@ejabberd_listener:accept:333 (#Port<0.16419>) Accepted connection 127.0.0.1:62395 -> 127.0.0.1:5280
2016-02-09 09:47:12.177 [debug] <0.546.0>@ejabberd_http:init:154 S: [{[<<"websocket">>],ejabberd_http_ws},{[<<"oauth">>],ejabberd_oauth},{[<<"api">>],mod_http_api},{[<<"register">>],mod_register_web},{[<<"admin">>],ejabberd_web_admin},{[<<"http-bind">>],mod_http_bind}]
2016-02-09 09:47:12.177 [info] <0.546.0>@ejabberd_http:init:158 started: {gen_tcp,#Port<0.16419>}
2016-02-09 09:47:12.177 [debug] <0.546.0>@ejabberd_http:process_header:281 (#Port<0.16419>) http query: 'GET' <<"/api/connected_users">>
2016-02-09 09:47:12.177 [debug] <0.546.0>@ejabberd_http:process:353 [<<"api">>,<<"connected_users">>] matches [<<"api">>]
2016-02-09 09:47:12.178 [info] <0.546.0>@mod_http_api:log:388 Admin call connected_users [] from 127.0.0.1:62395
那么如何配置Ejabberd让管理
用户请求所有Ejabberd REST Web服务?
So how to configure Ejabberd to allow the admin
user to request all the Ejabberd REST Web Services ?
我的用户存储在MySQL中,OAuth的令牌存储在Mnesia的会不会是什么问题?
My users are stored in Mysql, as OAuth Tokens are stored in Mnesia could it be the problem ?
谢谢,
巴蒂斯特
推荐答案
要知道,如果它在ejabberd.yml这样的规定输入用户名时,您正在使用@host。因为我只用管理员用户,当应在用户名admin @,某我没有收到来自REST请求任何回应。
Be sure you are using the @host when entering username if it's specified in that way in ejabberd.yml. I wasn't receiving any response from REST requests because I was using just admin for user, when should be admin@somehost in user name.
请让我知道如果这没有帮助。
Please let me know if this doesn't help.
这篇关于Ejabberd的OAuth / REST 401未经授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!