2

ユーザーのアクセストークンを取得しようとすると、このエラーが発生します。これは、Facebookアプリケーションの承認プロセスと関係があります。その例外を生成するコードは次のとおりです。

OAuthClientRequest oAuthRequest = OAuthClientRequest
    .tokenLocation("https://graph.facebook.com/oauth/access_token")
    .setGrantType(GrantType.AUTHORIZATION_CODE)
    .setClientId("myAppId")
    .setClientSecret("myAppSecret")
    .setRedirectURI("myAppURL").setCode(code)
    .buildBodyMessage();

そして、スローされた例外は以下のとおりです。

12:14:22,468 ERROR [STDERR] OAuthProblemException{description='Missing parameters:   
access_token', error='invalid_request', uri='null', state='null', scope='null'}
12:14:22,468 ERROR [STDERR]     
at org.apache.amber.oauth2.common.exception.OAuthProblemException.error(OAuthProblemException.java:57)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.common.utils.OAuthUtils.handleOAuthProblemException(OAuthUtils.java:165)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.common.utils.OAuthUtils.handleMissingParameters(OAuthUtils.java:183)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateRequiredParameters(OAuthClientValidator.java:90)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateParameters(OAuthClientValidator.java:53)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validate(OAuthClientValidator.java:49)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.response.OAuthClientResponse.validate(OAuthClientResponse.java:61)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.response.OAuthClientResponse.init(OAuthClientResponse.java:56)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.response.OAuthAccessTokenResponse.init(OAuthAccessTokenResponse.java:52)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.response.OAuthClientResponseFactory.createCustomResponse(OAuthClientResponseFactory.java:60)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.URLConnectionClient.execute(URLConnectionClient.java:105)
12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.OAuthClient.accessToken(OAuthClient.java:58)
12:14:22,469 ERROR [STDERR] at tpc.facebook.autenticacion.ServletOAuth2.obtenerCodeYAccessToken(ServletOAuth2.java:315)
12:14:22,469 ERROR [STDERR] at tpc.facebook.autenticacion.ServletOAuth2.doGet(ServletOAuth2.java:217)
12:14:22,469 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
12:14:22,469 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:14:22,469 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
12:14:22,469 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)1
12:14:22,469 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
12:14:22,469 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
12:14:22,469 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
12:14:22,469 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
12:14:22,469 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
12:14:22,469 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
12:14:22,469 ERROR [STDERR] at java.lang.Thread.run(Thread.java:662)
4

2 に答える 2

4

クライアントとサーバーの実装で同じ問題が発生しました。問題は、Apache Amber(Oltu)プロジェクトのクライアントの例の1つの間違いに関するものです。

まず、Authコードリクエストがあります(これは機能します):

OAuthClientRequest request = OAuthClientRequest
 .authorizationLocation(AUTHORIZE_URL)
 .setClientId(CLIENT_ID)
 .setRedirectURI(REDIR_URL)
 .setResponseType(CODE_RESPONSE)
 .**buildQueryMessage**();

次に、アクセストークンに関するリクエスト(機能しません):

OAuthClientRequest request = OAuthClientRequest
  .tokenLocation(ACCESS_TOKEN_URL)
  .setGrantType(GrantType.AUTHORIZATION_CODE)
  .setClientId(CLIENT_ID)
  .setClientSecret(CLIENT_SECRET)
  .setRedirectURI(REDIR_URL)
  .setCode(code)
  .**buildBodyMessage**();

間違いは、2番目のリクエストのbuildBodyMessage()に関するものです。buildQueryMessage()で変更します。

楽しみ :)

于 2013-08-21T16:45:51.583 に答える
1

通常のOAuthJSONAccessTokenResponseを使用できると思います。

OAuthAccessTokenResponse oAuthResponse = oAuthClient.accessToken(request);

私の問題は、Facebookが次のように応答することです

OAuthProblemException{description='null', error='{"message":"Error validating verification code.","type":"OAuthException","code":100}', uri='null', state='null', scope='null'}

何か案は?

于 2012-05-12T16:33:33.913 に答える