java - org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: 'Invalid request token' -
hi can someon me code goes great till point token accesstoken = service.getaccesstoken(requesttoken, verifier); after error error com.opensymphony.xwork2.interceptor.exceptionmappinginterceptor- response body incorrect. can't extract token , secret this: 'invalid request token' org.scribe.exceptions.oauthexception: response body incorrect. can't extract token , secret this: 'invalid request token' new in java , scribes
import org.scribe.builder.*; import org.scribe.builder.api.*; import org.scribe.model.*; import org.scribe.oauth.*; import com.opensymphony.xwork2.actionsupport; public class signintwitter extends actionsupport { private static final long serialversionuid = -4223895098942228518l; private static final string protected_resource_url = "https://api.twitter.com/1/statuses/update.json"; public string execute() { oauthservice service = new servicebuilder().provider(twitterapi.class) .apikey("xxxxxxxxxxxxxxxxx") .apisecret("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") .callback("http://127.0.0.1:8080/signintwitter").build(); // obtain request token token requesttoken = service.getrequesttoken(); string authurl = service.getauthorizationurl(requesttoken); verifier verifier = new verifier(authurl); token accesstoken = service.getaccesstoken(requesttoken, verifier); oauthrequest request = new oauthrequest(verb.post, protected_resource_url); request.addbodyparameter("status", "this sparta! *"); service.signrequest(accesstoken, request); response response = request.send(); return "success"; } }
ok added code
error com.opensymphony.xwork2.interceptor.exceptionmappinginterceptor- response body incorrect. can't extract token , secret this: 'invalid request token' org.scribe.exceptions.oauthexception: response body incorrect. can't extract token , secret this: 'invalid request token' @ org.scribe.extractors.tokenextractorimpl.extract(tokenextractorimpl.java:41) @ org.scribe.extractors.tokenextractorimpl.extract(tokenextractorimpl.java:27) @ org.scribe.oauth.oauth10aserviceimpl.getaccesstoken(oauth10aserviceimpl.java:103) @ org.scribe.oauth.oauth10aserviceimpl.getaccesstoken(oauth10aserviceimpl.java:84) @ org.scribe.oauth.oauth10aserviceimpl.getaccesstoken(oauth10aserviceimpl.java:89) @ com.lingleonline.webclient.controllers.signintwitter.execute(signintwitter.java:32) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ com.opensymphony.xwork2.defaultactioninvocation.invokeaction(defaultactioninvocation.java:453) @ com.opensymphony.xwork2.defaultactioninvocation.invokeactiononly(defaultactioninvocation.java:292) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:255) @ com.opensymphony.xwork2.interceptor.defaultworkflowinterceptor.dointercept(defaultworkflowinterceptor.java:176) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.validator.validationinterceptor.dointercept(validationinterceptor.java:265) @ org.apache.struts2.interceptor.validation.annotationvalidationinterceptor.dointercept(annotationvalidationinterceptor.java:68) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.conversionerrorinterceptor.intercept(conversionerrorinterceptor.java:138) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.parametersinterceptor.dointercept(parametersinterceptor.java:236) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.parametersinterceptor.dointercept(parametersinterceptor.java:236) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.staticparametersinterceptor.intercept(staticparametersinterceptor.java:190) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ org.apache.struts2.interceptor.fileuploadinterceptor.intercept(fileuploadinterceptor.java:243) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.modeldriveninterceptor.intercept(modeldriveninterceptor.java:100) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.chaininginterceptor.intercept(chaininginterceptor.java:145) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.prepareinterceptor.dointercept(prepareinterceptor.java:171) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ org.apache.struts2.interceptor.servletconfiginterceptor.intercept(servletconfiginterceptor.java:164) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ org.apache.struts2.interceptor.debugging.debugginginterceptor.intercept(debugginginterceptor.java:256) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.defaultworkflowinterceptor.dointercept(defaultworkflowinterceptor.java:176) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.validator.validationinterceptor.dointercept(validationinterceptor.java:265) @ org.apache.struts2.interceptor.validation.annotationvalidationinterceptor.dointercept(annotationvalidationinterceptor.java:68) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.conversionerrorinterceptor.intercept(conversionerrorinterceptor.java:138) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.parametersinterceptor.dointercept(parametersinterceptor.java:236) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.parametersinterceptor.dointercept(parametersinterceptor.java:236) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.staticparametersinterceptor.intercept(staticparametersinterceptor.java:190) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ org.apache.struts2.interceptor.multiselectinterceptor.intercept(multiselectinterceptor.java:75) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ org.apache.struts2.interceptor.checkboxinterceptor.intercept(checkboxinterceptor.java:90) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ org.apache.struts2.interceptor.fileuploadinterceptor.intercept(fileuploadinterceptor.java:243) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.modeldriveninterceptor.intercept(modeldriveninterceptor.java:100) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.scopedmodeldriveninterceptor.intercept(scopedmodeldriveninterceptor.java:141) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.chaininginterceptor.intercept(chaininginterceptor.java:145) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.prepareinterceptor.dointercept(prepareinterceptor.java:171) @ com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.i18ninterceptor.intercept(i18ninterceptor.java:176) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ org.apache.struts2.interceptor.servletconfiginterceptor.intercept(servletconfiginterceptor.java:164) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.aliasinterceptor.intercept(aliasinterceptor.java:192) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.opensymphony.xwork2.interceptor.exceptionmappinginterceptor.intercept(exceptionmappinginterceptor.java:187) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.lingleonline.webclient.controllers.checksession.intercept(checksession.java:91) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ com.lingleonline.webclient.controllers.maintenancecheck.intercept(maintenancecheck.java:74) @ com.opensymphony.xwork2.defaultactioninvocation.invoke(defaultactioninvocation.java:249) @ org.apache.struts2.impl.strutsactionproxy.execute(strutsactionproxy.java:54) @ org.apache.struts2.dispatcher.dispatcher.serviceaction(dispatcher.java:511) @ org.apache.struts2.dispatcher.ng.executeoperations.executeaction(executeoperations.java:77) @ org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter.dofilter(strutsprepareandexecutefilter.java:91) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:243) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:222) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:123) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:171) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:936) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1004) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:312) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:722)
you have create requesttoken oauth_token , oauth_verifier in redirected page :
http://www.example.com/xxxx?oauth_token=xxxxxx&oauth_verifier=xxxxxxx
try{ oauthservice servicetwitter = twitterfacade.getservice(); token requesttoken = new token(facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap().get("oauth_token"),facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap().get("oauth_verifier")); string codes_twitter=facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap().get("oauth_verifier"); system.out.println("code_twitter: "+codes_twitter); verifier verifier_twitter = new verifier(codes_twitter); token accesstoken_twitter = servicetwitter.getaccesstoken(requesttoken, verifier_twitter); token_twitter=accesstoken_twitter.gettoken(); system.out.println("token_twitter : "+token_twitter); loginbean.token=token_twitter; }catch (exception e) { e.printstacktrace(); }
Comments
Post a Comment