org.springframework.social.twitter.connect.TwitterConnectionFactory Java Examples
The following examples show how to use
org.springframework.social.twitter.connect.TwitterConnectionFactory.
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: SocialLogin.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(value = "/twitterLogin") public void printWelcome(HttpServletResponse response,HttpServletRequest request) { TwitterConnectionFactory connectionFactoryTwitter = new TwitterConnectionFactory("<consumer id>","<consumer key>"); OAuth1Operations oauth1Operations = connectionFactoryTwitter.getOAuthOperations(); OAuthToken requestToken = oauth1Operations.fetchRequestToken("http://www.localhost:8080/ch08/erp/twitterAuthentication.html", null); String authorizeUrl = oauth1Operations.buildAuthorizeUrl(requestToken.getValue(), OAuth1Parameters.NONE); try { response.sendRedirect(authorizeUrl); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example #2
Source File: SocialLogin.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(value = "/twitterAuthentication") public RedirectView callback(@RequestParam(value = "oauth_token") String oauthToken, @RequestParam(value = "oauth_verifier") String oauthVerifier) { TwitterConnectionFactory connectionFactoryTwitter = new TwitterConnectionFactory("<consumer id>","<consumer key>"); OAuth1Operations oauth1Operations = connectionFactoryTwitter.getOAuthOperations(); OAuthToken requestToken = oauth1Operations.fetchRequestToken("http://www.localhost:8080/ch08/erp/twitterAuthentication.html", null); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); OAuthToken accessToken = oauth1Operations.exchangeForAccessToken(new AuthorizedRequestToken(requestToken, oauthVerifier), OAuth1Parameters.NONE); if(accessToken.equals("<enter access token here>")){ redirectView.setUrl("/erp/paymentmodes.xml"); }else{ redirectView.setUrl("http://www.google.com"); } return redirectView; }
Example #3
Source File: SocialConfig.java From blog-social-login-with-spring-social with Apache License 2.0 | 6 votes |
@Override public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) { connectionFactoryConfigurer.addConnectionFactory(new FacebookConnectionFactory( environment.getProperty("spring.social.facebook.appId"), environment.getProperty("spring.social.facebook.appSecret"))); connectionFactoryConfigurer.addConnectionFactory(new TwitterConnectionFactory( environment.getProperty("twitter.consumerKey"), environment.getProperty("twitter.consumerSecret"))); connectionFactoryConfigurer.addConnectionFactory(new LinkedInConnectionFactory( environment.getProperty("spring.social.linkedin.appId"), environment.getProperty("spring.social.linkedin.appSecret"))); connectionFactoryConfigurer.addConnectionFactory(new GoogleConnectionFactory( environment.getProperty("spring.social.google.appId"), environment.getProperty("spring.social.google.appSecret"))); connectionFactoryConfigurer.addConnectionFactory(new GitHubConnectionFactory( environment.getProperty("spring.social.github.appId"), environment.getProperty("spring.social.github.appSecret"))); connectionFactoryConfigurer.addConnectionFactory(new LiveConnectionFactory( environment.getProperty("spring.social.live.appId"), environment.getProperty("spring.social.live.appSecret"))); }
Example #4
Source File: TwitterCredentialProviderFactory.java From syndesis with Apache License 2.0 | 5 votes |
static CredentialProvider createCredentialProvider(final SocialProperties properties) { final TwitterConnectionFactory twitter = new TwitterConnectionFactory(properties.getAppId(), properties.getAppSecret()); final OAuth1Applicator applicator = new OAuth1Applicator(properties); applicator.setConsumerKeyProperty("consumerKey"); applicator.setConsumerSecretProperty("consumerSecret"); applicator.setAccessTokenSecretProperty("accessTokenSecret"); applicator.setAccessTokenValueProperty("accessToken"); return new OAuth1CredentialProvider<>("twitter", twitter, applicator); }
Example #5
Source File: _SocialConfiguration.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 4 votes |
@Override public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) { // Google configuration String googleClientId = environment.getProperty("spring.social.google.clientId"); String googleClientSecret = environment.getProperty("spring.social.google.clientSecret"); if (googleClientId != null && googleClientSecret != null) { log.debug("Configuring GoogleConnectionFactory"); connectionFactoryConfigurer.addConnectionFactory( new GoogleConnectionFactory( googleClientId, googleClientSecret ) ); } else { log.error("Cannot configure GoogleConnectionFactory id or secret null"); } // Facebook configuration String facebookClientId = environment.getProperty("spring.social.facebook.clientId"); String facebookClientSecret = environment.getProperty("spring.social.facebook.clientSecret"); if (facebookClientId != null && facebookClientSecret != null) { log.debug("Configuring FacebookConnectionFactory"); connectionFactoryConfigurer.addConnectionFactory( new FacebookConnectionFactory( facebookClientId, facebookClientSecret ) ); } else { log.error("Cannot configure FacebookConnectionFactory id or secret null"); } // Twitter configuration String twitterClientId = environment.getProperty("spring.social.twitter.clientId"); String twitterClientSecret = environment.getProperty("spring.social.twitter.clientSecret"); if (twitterClientId != null && twitterClientSecret != null) { log.debug("Configuring TwitterConnectionFactory"); connectionFactoryConfigurer.addConnectionFactory( new TwitterConnectionFactory( twitterClientId, twitterClientSecret ) ); } else { log.error("Cannot configure TwitterConnectionFactory id or secret null"); } // jhipster-needle-add-social-connection-factory }
Example #6
Source File: TwitterProviderConfig.java From AIDR with GNU Affero General Public License v3.0 | 4 votes |
@Override protected ConnectionFactory<Twitter> createConnectionFactory() { return new TwitterConnectionFactory( twitterConsumerKey, twitterConsumerSecret); }
Example #7
Source File: TwitterProviderConfig.java From AIDR with GNU Affero General Public License v3.0 | 4 votes |
@Override protected ConnectionFactory<Twitter> createConnectionFactory() { return new TwitterConnectionFactory( twitterConsumerKey, twitterConsumerSecret); }