I am working on integrating Spring Social with a GWT app I am building. The app is Twitter specific and the only way to login to the app is to authenticate via Twitter.
The first time the user goes to the home page, as he is not logged in, he will be presented with a link to authenticate via Twitter. This link is generated in a process similar to the code block below:
The user clicks on the link, authorizes the app, and Twitter redirects back to the OAuth callback with a verifier. This time a block of code like the one given below is executed:Code:OAuthToken requestToken = createRequestToken(); session.setAttribute(REQUEST_TOKEN_SESSION_KEY, requestToken); String loginLink = createLoginUrl(requestToken);
Now let's pretend that I persist this connection for later use. As long as the user is not logged out and the session is not invalidated I can reuse it with no problem: I can store the ConnectionKey in the session and use it to fetch the connection from the database. But after the user logs out, the process above has to be repeated and after getting back the oauthVerifier, I see no way to avoid invoking connectionFactory.createConnection(accessToken) and instead reuse the persisted connection. Or am I missing something? Is there a way to reuse the persisted connection when the user wants to log in again?Code:private Connection<Twitter> createConnection(OAuthToken requestToken, String oauthVerifier) { TwitterConnectionFactory connectionFactory = (TwitterConnectionFactory) connectionFactoryLocator.getConnectionFactory(Twitter.class); OAuth1Operations oauthOperations = connectionFactory.getOAuthOperations(); AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(requestToken, oauthVerifier); OAuthToken accessToken = oauthOperations.exchangeForAccessToken(authorizedRequestToken, null); return connectionFactory.createConnection(accessToken); }
Thanks in advance,
Behrang


Reply With Quote
