spring social twitter MissingAuthorizationException

夙愿已清 提交于 2019-12-11 17:23:55

问题


I tried to post a tweet using Spring Social as described in this tutorial: https://docs.spring.io/spring-social-twitter/docs/current/reference/htmlsingle/. However I am getting

org.springframework.social.MissingAuthorizationException: Authorization is required for the operation, but the API binding was created without authorization.

My code looks as follows

TwitterTemplate twitterTemplate = new TwitterTemplate("key", "secret");
TweetData tweetData =new TweetData("test screenshot").withMedia(new ByteArrayResource(object.getScreenshot().getBytes()));
Tweet postResult = twitterTemplate.timelineOperations().updateStatus(tweetData);

回答1:


certain operations require a separate access token to be passed along with TwitterTemplate:

new TwitterTemplate(consumerKey, consumerSecret, accessToken, accessTokenSecret);

access tokens can be generated here: apps.twitter.com/app/"appId"/keys



来源:https://stackoverflow.com/questions/47739751/spring-social-twitter-missingauthorizationexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!