- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要用 Java 中的 Mendeley 创建一个应用程序。但我对 oauth2 的连接有问题。
我使用 Apache Oltu,但如果您知道其他更好的选择,请告诉我。
我有这个:
OAuthClientRequest request = OAuthClientRequest
.tokenLocation("https://api-oauth2.mendeley.com/oauth/token")
.setGrantType(GrantType.AUTHORIZATION_CODE)
.setClientId(CLIENT_ID)
.setClientSecret(CLIENTE_SECRET)
.setRedirectURI(REDIRECT_URI)
.setCode("code")
.setScope("all")
.buildQueryMessage();
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
GitHubTokenResponse oAuthResponse = oAuthClient.accessToken(request, GitHubTokenResponse.class);
String accessToken = oAuthResponse.getAccessToken();
String expiresIn = oAuthResponse.getExpiresIn().toString();
System.out.println("ACCESS TOKEN: " + accessToken);
System.out.println("EXPIRES IN : " + expiresIn);
但这会产生此异常:
Exception in thread "main" OAuthProblemException{error='invalid_request', description='Missing parameters: access_token', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}}
at org.apache.oltu.oauth2.common.exception.OAuthProblemException.error(OAuthProblemException.java:59).......
有什么想法吗?我再说一遍,如果您知道其他替代方案或解决方案,请帮助我。
非常感谢。
最佳答案
我们的网站上有一些文档:http://apidocs.mendeley.com/home/authentication
我使用 Apache Oltu 库和 Apache HTTP 客户端库构建了一个更完整的示例。这使用匿名访问 token 。
编辑
OAuthClientRequest request = OAuthClientRequest
.tokenLocation(TOKEN_URL)
.setClientId(TRUSTED_CLIENT_ID)
.setClientSecret(TRUSTED_SECRET)
.setGrantType(GrantType.CLIENT_CREDENTIALS)
.setScope("all")
.buildBodyMessage();
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
OAuthJSONAccessTokenResponse tokenResponse = oAuthClient.accessToken(
request, OAuthJSONAccessTokenResponse.class);
HttpGet httpGet = new HttpGet(CATALOG_URL);
httpGet.setHeader("Authorization", "Bearer " + tokenResponse.getAccessToken());
HttpResponse httpResponse = apacheHttpClient.execute(httpGet);
assertThat(httpResponse.getStatusLine().getStatusCode()).isEqualTo(200);
String responseAsString = EntityUtils.toString(httpResponse.getEntity());
ObjectMapper mapper = new ObjectMapper();
Document document = mapper.readValue(responseAsString, Document.class);
assertThat(document.getTitle()).isEqualTo("Identifying and recording user actions to enable automatic online assessment");
关于java - 使用 Java 实现 Mendeley 中的 Oauth 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23545198/
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 去年关闭。 Improve this questio
我想要一个脚本来查询我的 Mendeley 桌面以获取文章列表。这可能吗(在任何脚本语言中,包括 shell)?我知道有一个 API 可以通过 http 使用,但是当我没有连接到 Internet 时
Mendeley 有一个 Catalog Search -> Search by query API,如下所示: curl ' https://api.mendeley.com/search/cata
我正在尝试使用 Mendeley API 来上传和检索文档和文件,但在使用 files/{file_id} 时遇到了问题。端点。 我有一个用于测试的个人 Mendeley 帐户,其中包含一些 PDF
我有一个 mendeley 帐户,我正在使用他们的在线版本。我创建了一个用户 ID 和客户端 key ,将其保存在 config.yml 文件中并使用它进行身份验证。我正在使用 their websi
我正在阅读来自 here 的 Mendeley 文档.我正在尝试在我的控制台中获取数据,我正在使用教程中的以下代码 from mendeley import Mendeley # These valu
我一直在使用 Mendeley 的 Microsoft Word 插件轻松引用我的 Mendeley 桌面图书馆中的论文。 但是,我注意到 IEEE 格式的引用书目/引文在引用 session 记录和
Mendeley有一个很棒的 API(事实上他们已经使用他们的 API 发起了一场比赛,不过这个问题并不是特定的),它使用 OAuth。 我正在尝试编写一个允许 Mendeley 身份验证的策略,
我目前正在尝试使用 Java 和 net.oauth 库向 Mendeley 进行身份验证。我的目标是从 Mendeley 检索读者数据,并将其添加到我们的学术文档数据库中。 不幸的是,我目前收到 4
使用新的 Mendeley API,似乎不再有办法对文档进行全文搜索。只是没有记录吗?会添加吗?还是永远消失了? 最佳答案 我们目前正在开发全文搜索功能,希望很快就能发布。 关于Mendeley Oa
我最近升级了我的 linux (debian)。从那时起,我的 Mendeley 就无法正常工作:它启动并在几秒钟后开始获取并立即崩溃。 这是它给出的错误信息: Qt WebEngine Plugin
我需要用 Java 中的 Mendeley 创建一个应用程序。但我对 oauth2 的连接有问题。 我使用 Apache Oltu,但如果您知道其他更好的选择,请告诉我。 我有这个: OAuthCli
我似乎无法弄清楚调用 Mendeley 的 authenticated API 的 OAuth 身份验证(请注意,公共(public)方法有一个未维护的 gem here )。 我在他们的门户网站上创
我有一个应用程序在 Mendeley 上与 OAuth1 配合得很好。由于不再支持 OAth1,我必须将我的应用程序迁移到 OAuth2 才能获取数据。 我收到 token 响应,但无法请求任何内容,
我正在尝试编写 Java 代码以使用其文档 API 将文章 PDF 上传到 Mendeley,但我不断收到 500 错误。我是 Java 新手,所以我可能只是使用了错误的代码或库。最终,目标是通过 M
我在工作中在 MacOS 中使用 Mendeley,在家在 Ubuntu 中使用 Mendeley,并且希望将我的库与两台计算机中的 Dropbox 文件夹同步。我知道可以与 Dropbox 同步,但
我是一名优秀的程序员,十分优秀!