Spring Social with JavaConfig (Part 2)

Review

In the previous section, we have discussed the functional requirements of our application. In this section we will study how to generate OAuth keys for Facebook and Twitter. These are required so that Spring Social can communicate with these social media sites.

Table of Contents

Click on a link to jump to that section:
  1. Functional Specs
  2. Generate OAuth keys
    • Facebook
    • Twitter
  3. Spring Social configuration
  4. Spring Security configuration
  5. JavaConfig
    • ApplicationInitializer.java
    • ApplicationContext.java
    • DataConfig.java
    • ThymeleafConfig.java
    • spring.properties
  6. View with Thymeleaf
  7. Layers
    • Domain
    • Repository
    • Service
    • Controller
  8. Running the application
    • Clone from GitHub
    • Create the Database
    • Run with Maven and Tomcat 7
    • Run with Maven and Jetty 8
    • Import to Eclipse
    • Validate with W3C

Generate OAuth keys

Facebook

To generate a Facebook secret key, you need to sign-up for a Facebook account first. Once you have an account, follow these steps:
  1. Open a browser
  2. Visit https://developers.facebook.com/apps
  3. Click on Create New App
  4. Fill-in the App Name
  5. You will be redirected to the Basic settings page
  6. Now copy the App ID value. This is your client ID
  7. Then copy the App Secret value. This is your client secret

Note: The values need to be stored in the spring.properties file (see Part 5).

On my sample app, here's the Basic settings page. I've purposely changed the App ID and App Secret values:


Twitter

To generate a Twitter secret key, you need to sign-up for a Twitter account first. Once you have an account, follow these steps:
  1. Open a browser
  2. Visit https://dev.twitter.com/
  3. Visit the My applications page at https://dev.twitter.com/apps
  4. Click on Create a new application
  5. Fill-in the Name
  6. Fill-in the Description
  7. Fill-in the Website (You will need to invent a fictitious URL)
  8. You will be redirected to the Details tab of your new application
  9. Now copy the Consumer key value. This is your client ID
  10. Then copy the Consumer secret value. This is your client secret

Note: The values need to be stored in the spring.properties file (see Part 5).

On my sample app, here's the Details tab. I've purposely changed the Consumer key and Consumer secret values:



Next

In the next section, we will setup the Spring Social-related configuration through JavaConfig. Click here to proceed.

0 komentar:

Post a Comment