Setting up provider details in application.properties

If you run the application (./mvnw spring-boot:run) and then navigate your browser to http://localhost:8080, you will see a default login page, as follows. The entire magic behind this page is done for you by Spring Boot and Spring Security:

Figure 7: Default Spring Boot + Spring Security project created using Spring Initializr

Open the application.properties file (src/main/resources) and add the following properties:

#Google app details
spring.security.oauth2.client.registration.google.client-id=1085570125650-l8j2r88b5i5gbe3vkhtlf8j7u3hvdu78.apps.googleusercontent.com
spring.security.oauth2.client.registration.google.client-secret=MdtcKp-ArG51FeqfAUw4K8Mp
#Facebook app details
spring.security.oauth2.client.registration.facebook.client-id=229630157771581
spring.security.oauth2.client.registration.facebook.client-secret=e37501e8adfc160d6c6c9e3c8cc5fc0b
#Github app details
spring.security.oauth2.client.registration.github.client-id=<your client id>
spring.security.oauth2.client.registration.github.client-secret=<your client secret>
#Spring MVC details
spring.mvc.view.prefix: /WEB-INF/views/
spring.mvc.view.suffix: .jsp

Here, we declare two properties for each provider. We will be implementing the Google provider, but you can add any number of providers. Just adding these properties will create more magic, and your login page will suddenly change to the following:

Figure 8: OAuth default login page when application.properties file is modified

The providers (links) shown in the preceding screenshot are according to the configurations seen in the application.properties file. It just looks for two properties, as follows:

spring.security.oauth2.client.registration.<provider_name>.client-id=<client id>
spring.security.oauth2.client.registration.<provider_name>.client-secret=<client secret>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.138.138