@Override
public InteractionState<LinkedinAccessTokenContext> processOAuthInteraction(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, OAuthException {
HttpSession session = httpRequest.getSession();
//See if we are a callback
Token requestToken = (Token) session.getAttribute(OAuthConstants.ATTRIBUTE_LINKEDIN_REQUEST_TOKEN);
if (requestToken == null) {
requestToken = oAuthService.getRequestToken();
String redirect = oAuthService.getAuthorizationUrl(requestToken);
oAuthService.getRequestToken();
httpResponse.sendRedirect(redirect);
session.setAttribute(OAuthConstants.ATTRIBUTE_LINKEDIN_REQUEST_TOKEN, requestToken);
return new InteractionState<LinkedinAccessTokenContext>(InteractionState.State.AUTH, null);
} else {
session.removeAttribute(OAuthConstants.ATTRIBUTE_LINKEDIN_REQUEST_TOKEN);
String verifierCode = httpRequest.getParameter("oauth_verifier");
Verifier verifier = new Verifier(verifierCode);
Token accessToken = oAuthService.getAccessToken(requestToken, verifier);
LinkedinAccessTokenContext accessTokenContext = new LinkedinAccessTokenContext(accessToken, this.oAuthService);
return new InteractionState<LinkedinAccessTokenContext>(InteractionState.State.FINISH, accessTokenContext);
}
}