【问题标题】:openfire rest api plugin always response 403 Forbiddenopenfire rest api插件总是响应403 Forbidden
【发布时间】:2015-08-24 08:49:30
【问题描述】:

我在 openfire 管理页面的插件页面启用了 REST API 插件

并通过 Postman 向以下 url 发送 GET 请求,这是 chrome 的扩展:

http://my.host.com:9090/plugins/restapi/v1/users

我得到了这个回复

Access-Control-Allow-Credentials → true
Access-Control-Allow-Headers → origin, content-type, accept, authorization
Access-Control-Allow-Methods → GET, POST, PUT, DELETE, OPTIONS, HEAD
Access-Control-Allow-Origin → *
Content-Length → 0
Date → Mon, 24 Aug 2015 08:41:42 GMT

我不知道我的步骤出了什么问题。谁能告诉我?

非常感谢

【问题讨论】:

  • 你确定你得到的是 403 而不是 401?这意味着您提供的标头授权没有到位或错误。

标签: xmpp openfire


【解决方案1】:

“启用”REST API 可能意味着“安装”插件。因为在你成功安装之后。您必须转到“服务器设置”->“REST API”,然后选中“启用”。您也可以在那里选择“HTTP Basic Auth”或“Secret key auth”,然后保存您的更改。 Documentation

【讨论】:

    【解决方案2】:

    你不能简单地访问api地址,必须在代码中为你的请求头添加授权:

     httprequest.Headers.Add("Authorization:theSecretKeyInConfigPage");
    

    你可以使用 fidder 来模拟一个 httprequest :

    GET http://yourdomain.com:9090/plugins/restapi/v1/sessions HTTP/1.1
    Accept: application/json
    Authorization: yoursecretkey
    Host:yourdomain.com:9090
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-02-24
      • 2017-05-15
      • 1970-01-01
      • 1970-01-01
      • 2018-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多