在我的操作中,我将请求令牌存储如下:
//TwitterOath
public String execute(){
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
try {
RequestToken requestToken = twitter.getOAuthRequestToken(REDIRECT_URI);
authUrl = requestToken.getAuthenticationURL();
//session
Map<String, Object> session = ActionContext.getContext().getSession();
session.put("requestToken", requestToken);
} catch (TwitterException e) {
e.printStackTrace();
}
return SUCCESS;
}
在 REDIRECT_URI 操作中:
RequestToken requestToken = (RequestToken)
ActionContext.getContext().getSession().get("requestToken");
问题是有时 requestToken 为空。