Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/twin/spring-security-oauth2-client-example
Minimal configuration required for a Spring Boot project using Spring Security with OAuth2 client
https://github.com/twin/spring-security-oauth2-client-example
java oauth2-client spring spring-boot spring-framework spring-security spring-security-oauth2
Last synced: 2 months ago
JSON representation
Minimal configuration required for a Spring Boot project using Spring Security with OAuth2 client
- Host: GitHub
- URL: https://github.com/twin/spring-security-oauth2-client-example
- Owner: TwiN
- Created: 2018-04-05T20:39:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-07T02:14:31.000Z (over 5 years ago)
- Last Synced: 2024-10-11T16:04:36.237Z (2 months ago)
- Topics: java, oauth2-client, spring, spring-boot, spring-framework, spring-security, spring-security-oauth2
- Language: Java
- Homepage: https://twin.sh/articles/18/spring-security-how-to-configure-an-oauth2-client
- Size: 135 KB
- Stars: 29
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```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](https://console.developers.google.com/apis/credentials/)
- Create credentials > OAuth client ID![create credentials](img/create-credentials.png)
- Select **Web Application**
- Add `http://localhost` as Authorised JavaScript origins
- Add `http://localhost/login/oauth2/code/google` as Authorised redirect URIs![oauth-client-id-parameters](img/oauth-client-id-parameters.png)
- Click on **Create**
- Copy your client ID and your client secret as the value for
`spring.security.oauth2.client.registration.google.client-id` and
`spring.security.oauth2.client.registration.google.client-secret` respectively in the `application.properties` file.
- Done