java.lang.RuntimeException:com.google.gdata.client.authn.oauth.OAuthException:oauth_token_secret不存在

时间:2015-01-11 15:33:43

标签: java

无法从谷歌获取联系人。

代码是根据谷歌文档。

GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(CLIENT_ID);
oauthParameters.setOAuthConsumerSecret(CLIENT_SECRET);
oauthParameters.setOAuthToken(tokenData);
oauthParameters.setOAuthTokenSecret("");

contacstService.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer());

我打电话的时候:

ContactFeed resultFeed = contacstService.getFeed(feedUrl, ContactFeed.class);

获得运行时异常。

我正在使用Google+ API进行记录。

另外,我如何设置accesstoken秘密?

异常::

java.lang.RuntimeException: com.google.gdata.client.authn.oauth.OAuthException: oauth_token_secret does not exist.
    at com.google.gdata.client.GoogleAuthTokenFactory$OAuthToken.getAuthorizationHeader(GoogleAuthTokenFactory.java:214)
    at com.google.gdata.client.http.HttpGDataRequest.(HttpGDataRequest.java:338)
    at com.google.gdata.client.http.GoogleGDataRequest.(GoogleGDataRequest.java:457)
    at com.google.gdata.client.http.GoogleGDataRequest$Factory.createRequest(GoogleGDataRequest.java:94)
    at com.google.gdata.client.http.HttpGDataRequest$Factory.getRequest(HttpGDataRequest.java:165)
    at com.google.gdata.client.Service.createRequest(Service.java:760)
    at com.google.gdata.client.GoogleService.createRequest(GoogleService.java:539)
    at com.google.gdata.client.Service.createFeedRequest(Service.java:1156)
    at com.google.gdata.client.Service.getFeed(Service.java:997)
    at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:645)
    at com.google.gdata.client.Service.getFeed(Service.java:1017)
    at com.google.plus.samples.quickstart.Signin$PeopleServlet.contactsList(Signin.java:409)
    at com.google.plus.samples.quickstart.Signin$PeopleServlet.doGet(Signin.java:345)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

1 个答案:

答案 0 :(得分:-1)

我使用Google通讯录API,并尝试将setOAuthTokenSecret设置为access_token,运行良好。