spring social twitter MissingAuthorizationExceptio

2019-08-26 01:42发布

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条回答
男人必须洒脱
2楼-- · 2019-08-26 02:35

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

查看更多
登录 后发表回答