Java Code Examples for twitter4j.auth.AccessToken#getTokenSecret()

The following examples show how to use twitter4j.auth.AccessToken#getTokenSecret() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainController.java    From WTFDYUM with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/signin/callback", method = RequestMethod.GET)
public RedirectView signinCallback(@RequestParam("oauth_verifier") final String verifier,
        final HttpServletRequest request) throws WTFDYUMException {
    final RequestToken requestToken = (RequestToken) request.getSession().getAttribute(SESSION_REQUEST_TOKEN);
    request.getSession().removeAttribute(SESSION_REQUEST_TOKEN);

    final AccessToken accessToken = twitterService.completeSignin(requestToken, verifier);

    if (principalService.get(accessToken.getUserId()) == null) {
        userService.addEvent(accessToken.getUserId(), new Event(EventType.REGISTRATION, null));
    }

    final Principal user = new Principal(accessToken.getUserId(), accessToken.getToken(), accessToken.getTokenSecret());
    principalService.saveUpdate(user);
    authenticationService.authenticate(user);

    return new RedirectView("/user", true);
}
 
Example 2
Source File: TwitterSession.java    From vocefiscal-android with Apache License 2.0 6 votes vote down vote up
/**
 * Stores the session data on disk.
 * 
 * @param context
 * @return
 */
public boolean save(Context context, AccessToken accessToken) 
{

    Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();

    this.token = accessToken.getToken();
    this.tokensecret = accessToken.getTokenSecret();
    editor.putString(TOKEN, token);
    editor.putString(TOKENSECRET, tokensecret);
    

    if (editor.commit()) 
    {
        singleton = this;
        return true;
    }
    return false;
}
 
Example 3
Source File: TwitterOauthWizard.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
protected void onGotTwitterAccessToken (final AccessToken accessToken, final TwitterOauthComplete completeCallback) {
	try {
		LOG.i("Account authorised %s.", accessToken.getScreenName());
		final Account account = new Account(completeCallback.getAccountId(), accessToken.getScreenName(), AccountProvider.TWITTER,
				getTwitterConfiguration().getOAuthConsumerKey(), getTwitterConfiguration().getOAuthConsumerSecret(),
				accessToken.getToken(), accessToken.getTokenSecret());
		completeCallback.onAccount(account, accessToken.getScreenName());
	}
	catch (final Exception e) { // NOSONAR want to show any errors to the user.
		LOG.e("Failed to write new Twitter account.", e);
		DialogHelper.alert(getContext(), e);
	}
}