我需要用Java中的Mendeley创build一个应用程序。 但是我在oauth2的同时也遇到了问题。
我使用Apache Oltu,但如果你知道另一个更好的select,请告诉我。
我有这个:
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);
但是这产生了这个例外:
Symfony2functiontesting客户端强制服务器参数SERVER_NAME
PHP_imap.dll for PHP v 5.2.6 apache for windows
MacOSX在小牛升级后缺lessApache httpd.h文件(**已更新为优胜美地**)
OpenShift,Python 2.7和静态文件与htaccess
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).......
任何想法? 我再说一遍,如果你知道另一个select或解决scheme,请帮助我。
非常感谢。
防止执行父文件夹的.htaccess
如何重新编写锚定cms的指令
将Socket.IO添加到现有的Django / Wsgi项目中
需要在.htaccess重写规则中转义#(哈希/磅)字符
XDebug真的很慢
在我们的网站上有一些文档http://apidocs.mendeley.com/home/authentication
我把Apache Oltu库和Apache HTTP Client库放在一起,形成了一个更完整的例子。 这使用匿名访问令牌。
编辑
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");
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。