【问题标题】:Mendeley Implicit auth type not returning full dataMendeley 隐式身份验证类型不返回完整数据
【发布时间】:2015-04-22 14:39:37
【问题描述】:

这个问题与 Mendeley API 有关。 http://dev.mendeley.com/

使用隐式认证类型时:http://dev.mendeley.com/reference/topics/authorization_overview.html

我似乎只收到给定文档的一部分数据。例如,即使填充了“网站”字段,它似乎也无法通过。

我只是在使用隐式身份验证类型而不是其他身份验证类型时遇到此问题。

还有其他 Mendeley API 用户遇到过这种情况吗?这似乎是一个错误。

【问题讨论】:

  • 你的问题不清楚。请编辑您的问题。您可以找到有关如何撰写好问题的信息here
  • 感谢您的评论。希望我的问题现在更清楚了。

标签: mendeley


【解决方案1】:

根据您指定的文档视图返回某些字段。这是为了能够支持多个客户的需求,例如与大型网络客户端相比,移动客户端需要更小的数据集

请阅读-http://dev.mendeley.com/methods/#document-views

您需要在端点调用中指定“view=bib”。

这是一个仅使用 Java 的非常粗略的工作示例

@Test
public void testImplicitGrantFlow() {

    String random = RandomStringUtils.random(5);

    String query = String.format(
            "?client_id=%s&redirect_uri=%s&response_type=token&scope=all&state=%s", IMPLICIT_GRANT_FLOW_CLIENT_ID, "http://localhost:5000/callback", random);

    ClientResponse authorise = jerseyClient.resource(AUTH_URL + query)
            .accept(MediaType.APPLICATION_JSON)
            .get(ClientResponse.class);

    assertThat(authorise.getStatus()).isEqualTo(200);

    ClientResponse postFormDataResponse = jerseyClient.resource(AUTH_URL + query)
            .entity("username=joyce.stack@mendeley.com&password=spuds", MediaType.APPLICATION_FORM_URLENCODED_TYPE)
            .accept(MediaType.APPLICATION_JSON)
            .post(ClientResponse.class);
    assertThat(postFormDataResponse.getStatus()).isEqualTo(302);

    String queryString = postFormDataResponse.getHeaders().get("Location").get(0);

    Matcher matcher = ACCESS_TOKEN_REGEX.matcher(queryString);
    matcher.find();
    String accessToken = matcher.group(1);

    matcher = STATE_REGEX.matcher(queryString);
    matcher.find();
    String state = matcher.group(1);

    assertNotNull(accessToken);
    assertThat(queryString).contains(accessToken);

    assertNotNull(state);
    assertThat(queryString).contains(state);

    ClientResponse response = jerseyClient.resource(OAuthBaseClass.DOCUMENTS_URL)
            .header("Authorization", "Bearer " + accessToken)
            .get(ClientResponse.class);
    assertThat(response.getStatus()).isEqualTo(200);

    List<Document> documents = response.getEntity(new GenericType<List<Document>>() {
    });
    assertThat(documents.size()).isGreaterThan(0);

    ListIterator<Document> documentListIterator = documents.listIterator();
    while (documentListIterator.hasNext()) {
        Document next = documentListIterator.next();
          System.out.println(next.getTitle());
          System.out.println(next.getWebsites());

    }

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-26
    • 2021-01-01
    • 2013-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-16
    • 2015-11-09
    相关资源
    最近更新 更多