OAuthProblem,缺少参数的access_token [英] OAuthProblem, missing parameter access_token

查看:4143
本文介绍了OAuthProblem,缺少参数的access_token的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图得到一个用户的访问令牌收到此错误。这与一个Facebook应用程序的授权过程中做。在code产生的例外是以下内容:

  OAuthClientRequest oAuthRequest = OAuthClientRequest
    .tokenLocation(https://graph.facebook.com/oauth/access_token)
    .setGrantType(GrantType.AUTHORIZATION_ code)
    .setClientId(myAppId)
    .setClientSecret(myAppSecret)
    .setRedirectURI(myAppURL)。设置code(code)
    .buildBodyMessage();

和抛出的异常如下之下:

  12:14:22468错误[STDERR] OAuthProblemException {说明='缺少参数:
的access_token',错误='INVALID_REQUEST',URI ='空',国家='空',范围='空'}
12:14:22468错误[STDERR]
在org.apache.amber.oauth2.common.exception.OAuthProblemException.error(OAuthProblemException.java:57)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.common.utils.OAuthUtils.handleOAuthProblemException(OAuthUtils.java:165)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.common.utils.OAuthUtils.handleMissingParameters(OAuthUtils.java:183)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateRequiredParameters(OAuthClientValidator.java:90)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateParameters(OAuthClientValidator.java:53)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.client.validator.OAuthClientValidator.validate(OAuthClientValidator.java:49)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.client.response.OAuthClientResponse.validate(OAuthClientResponse.java:61)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.client.response.OAuthClientResponse.init(OAuthClientResponse.java:56)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.client.response.OAuthAccessTokenResponse.init(OAuthAccessTokenResponse.java:52)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.client.response.OAuthClientResponseFactory.createCustomResponse(OAuthClientResponseFactory.java:60)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.client.URLConnectionClient.execute(URLConnectionClient.java:105)
12:14:22468错误[STDERR]在org.apache.amber.oauth2.client.OAuthClient.accessToken(OAuthClient.java:58)
12:14:22469错误[STDERR]在tpc.facebook.autenticacion.ServletOAuth2.obtener codeYAccessToken(ServletOAuth2.java:315)
12:14:22469错误[STDERR]在tpc.facebook.autenticacion.ServletOAuth2.doGet(ServletOAuth2.java:217)
12:14:22469错误[STDERR]在javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
12:14:22469错误[STDERR]在javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
12:14:22469错误[STDERR]在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
12:14:22469错误[STDERR]在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:14:22469错误[STDERR]在org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
12:14:22469错误[STDERR]在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
12:14:22469错误[STDERR]在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:14:22469错误[STDERR]在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
12:14:22469错误[STDERR]在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
12:14:22469错误[STDERR]在org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)1
12:14:22469错误[STDERR]在org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
12:14:22469错误[STDERR]在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
12:14:22469错误[STDERR]在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
12:14:22469错误[STDERR]在org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
12:14:22469错误[STDERR]在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
12:14:22469错误[STDERR]在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
12:14:22469错误[STDERR]在org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
12:14:22469错误[STDERR]在org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:583)
12:14:22469错误[STDERR]在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:446)
12:14:22469错误[STDERR]在java.lang.Thread.run(Thread.java:662)


解决方案

我认为你可以使用正常的OAuthJSONAccessTokenResponse:

  OAuthAccessTokenResponse oAuthResponse = oAuthClient.accessToken(请求);

我的问题是,与Facebook的回应

  OAuthProblemException {说明='空',错误='{消息:错误验证验证code,类型:OAuthException,code:100},URI ='空',国家='空',范围='空'}

任何想法?

I'm getting this error while trying to get an access token for a user. This has to do with the authorization process of a facebook application. The code that produces that exception is the following:

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

And the exception thrown follows beneath:

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)

解决方案

I think you can use the normal OAuthJSONAccessTokenResponse:

OAuthAccessTokenResponse oAuthResponse = oAuthClient.accessToken(request);

my problem is, Facebook responds with

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

Any ideas?

这篇关于OAuthProblem,缺少参数的access_token的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆