https://github.com/hendisantika/spring-oauth2
A Simple Example implementation OAuth2 using Spring Boot
https://github.com/hendisantika/spring-oauth2
Last synced: about 2 months ago
JSON representation
A Simple Example implementation OAuth2 using Spring Boot
- Host: GitHub
- URL: https://github.com/hendisantika/spring-oauth2
- Owner: hendisantika
- Created: 2018-07-04T00:04:35.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-21T21:25:50.000Z (2 months ago)
- Last Synced: 2025-04-13T00:15:40.515Z (about 2 months ago)
- Language: Java
- Size: 188 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spring-oauth2
# Using Spring Oauth2 to secure REST
This project is part of a tutorial about Oauth2 authentication on Spring. You can read the material here.
### Tutorial's Summary
How to create from scratch a REST service with Spring Boot. We'll secure it using the Oauth2 protocol, using JSON Web Tokens, or JWT. There are several interesting materials scattered on the web, however, after studying a lot of then, I believe that the theme could be examined a little further. Instead of simply showing how to configure the server, I'll try to briefly explain why such configuration is necessary.
### To Build and Run
Go to the cloned directory and run `mvn spring-boot:run` or build with your chosen IDE.### Curl Commands
You should install [./JQ](https://stedolan.github.io/jq/) before running these Curl commands.### To get a new token
`curl trusted-app:secret@localhost:8080/oauth/token -d "grant_type=password&username=user&password=password" | jq`### To get a refresh token
`curl trusted-app:secret@localhost:8080/oauth/token -d "grant_type=refresh_token&jti=[JTI]&refresh_token=[REFRESH_TOKEN]" | jq`### To access a protected resource
`curl -H "Authorization: Bearer [ACCESS_TOKEN]" localhost:8080/api/hello`