【问题标题】:Authentication Error in using Alfresco Rest API使用 Alfresco Rest API 时的身份验证错误
【发布时间】:2013-05-17 14:20:43
【问题描述】:

我正在尝试使用我的独立休息代码访问 alfresco rest api。当我使用以下网址时,我得到了登录票 -

"http://host:port/alfresco/service/api/login?u=admin&pw=admin"

我拿到了票,但是我如何使用这张票与 alfresco 进行进一步的通信,而不会遇到这个身份验证问题。

以下是我用于与 alfresco rest 客户端通信的代码。

HttpGet getReq = new HttpGet(url);
getReq.addHeader("accept", "application/json");
StringEntity input = new StringEntity(args);
HttpResponse response = client.execute(getReq);

亲切的问候 加维特·贾恩

【问题讨论】:

  • 您的身份验证错误在哪里?如果您没有遇到错误,请编辑您的标题。

标签: rest authentication alfresco


【解决方案1】:

将 alf_ticket 参数附加到您的 URL 并传入您从 /api/login 调用中检索到的票证。见http://wiki.alfresco.com/wiki/Web_Scripts#Authenticating

【讨论】:

  • 嗨,杰夫,谢谢,现在我正在尝试使用以下 URL - localhost:9080/alfresco/service/api/search/… 并得到以下响应 - HTTP/1.1 401 Unauthorized [Server: Apache-Coyote/1.1, WWW-Authenticate: Basic realm="Alfresco", Content-Type: text/html;charset=utf-8, Content-Length: 951, Date: Mon, 20 May 2013 04:21:11 GMT] 请告知。谢谢
  • 当我从 Firefox 休息客户端点击相同的网址时,它工作正常。 url - localhost:9080/alfresco/service/api/search/… 响应 - 状态代码:200 OK 缓存控制:无缓存 内容类型:application/atom+xml;charset=UTF-8 日期:星期一,2013 年 5 月 20 日 04:33:24 GMT 到期:星期四, 1970 年 1 月 1 日 00:00:00 GMT Pragma: no-cache Server: Apache-Coyote/1.1 Transfer-Encoding: chunked
  • 在您的 Firefox REST 客户端中,看起来您正在发送“application/atom+xml”作为内容类型标头,这是正确的。与您发送的其余代码相同吗?
猜你喜欢
  • 1970-01-01
  • 2020-09-19
  • 2017-09-07
  • 2014-05-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多