This example makes use of in-memory client credentials and a symmetric signing key shared between both the Auth & Resource servers.
Start up both the applications:
- ./gradlew :auth-server:bootRun
- ./gradlew :resource-server:bootRun
Once they have both started, first make a request to the Auth server to get a JWT.
curl http://UserOne:Password@localhost:8080/oauth/token -d grant_type=client_credentials -d scope=write
curl http://UserTwo:Password@localhost:8080/oauth/token -d grant_type=client_credentials -d scope=read
Using the access_token
you received back from the Auth server, now make the call to the Resource server
replacing [TOKEN]
.
curl http://localhost:8081/resource -H"Authorization: Bearer [TOKEN]"
curl -X POST http://localhost:8081/resource -H"Authorization: Bearer [TOKEN]"