给出以下错误消息:
Authorization is required for the operation, but the API binding was created without authorization.
我能够获得时间轴上的推文,但无法发布状态。得到以下回应。
{
"timestamp": "2018-10-21T12:48:32.046+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Authorization is required for the operation, but the API binding was created without authorization.",
"path": "/twitter/post/"
}
。 这是我的代码:
@PostConstruct
public void init(){
//connectionFactory = new TwitterConnectionFactory(apiId, apiSecret);
twitterTemplate = new TwitterTemplate(apiId, apiSecret, accessToken, accessTokenSecret);
}
@RequestMapping(value = "/list")
public List<Tweet> getPostList(){
return twitter.timelineOperations().getHomeTimeline();
}
@RequestMapping(value = "/post", method = RequestMethod.PUT)
public Tweet postTweet(
@RequestParam(value = "text") String text) {
Tweet addedTweet;
addedTweet = twitterTemplate.timelineOperations().updateStatus(text);
return addedTweet;
}
任何人都可以帮助解决问题。我也尝试使用授权链接,但仍然收到AuthorizationException