spring-security-oauth2-client-example
                                
                                 spring-security-oauth2-client-example copied to clipboard
                                
                                    spring-security-oauth2-client-example copied to clipboard
                            
                            
                            
                        Minimal configuration required for a Spring Boot project using Spring Security with OAuth2 client
spring-security-oauth2-client-example
Modules
minimal-sample
This module contains the minimal configuration required for a Spring Boot project using Spring Security with OAuth2 client.
custom-userservice-sample
Same as minimal-sample, but it contains a custom OAuth2 UserService.
Note
For Google, it's actually possible to just use the two following properties:
spring.security.oauth2.client.registration.google.client-id=
spring.security.oauth2.client.registration.google.client-secret=
But for the sake of the example, I'll be inserting all properties.
Creating the API credentials
- Navigate to Google's Developer console
- Create credentials > OAuth client ID

- Select Web Application
- Add http://localhostas Authorised JavaScript origins
- Add http://localhost/login/oauth2/code/googleas Authorised redirect URIs

- Click on Create
- Copy your client ID and your client secret as the value for
spring.security.oauth2.client.registration.google.client-idandspring.security.oauth2.client.registration.google.client-secretrespectively in theapplication.propertiesfile.
- Done