Ejabberd的OAuth / REST 401未经授权

编程入门 行业动态 更新时间:2024-10-27 11:23:22
本文介绍了Ejabberd的OAuth / REST 401未经授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想请求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访问令牌的管理​​用户。

localhost:5280/oauth/authorization_token?response_type=token&client_id=myclient&redirect_uri=localhost:5280&scope=sasl_auth

它返回了我的OAuth令牌。

It returns me my OAuth Token.

localhost:5280/?access_token=oLn8Hebh051l2PdCM15tSvHrEI25CpBs&token_type=bearer&expires_in=3600&scope=sasl_auth&state=

最后,要求 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未经授权

本文发布于:2023-11-09 22:39:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573626.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未经授权   OAuth   Ejabberd   REST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!