Spring Boot Oauth2 with H2 database
Java Shell Batchfile
Switch branches/tags
Nothing to show
Clone or download
Latest commit 15fab24 Jan 3, 2016
Permalink
Failed to load latest commit information.
src add hello and ignore it from authenticating Dec 19, 2015
.gitignore ignore .mvn wrapper Oct 16, 2015
.travis.yml Added JDK Jan 3, 2016
README.md added build status to README Jan 3, 2016
mvnw Initial commit Oct 16, 2015
mvnw.cmd Initial commit Oct 16, 2015
pom.xml Initial commit Oct 16, 2015

README.md

Build Status

Build and Run

mvn clean install -DskipTests spring-boot:run

Usage

Checking app is deployed sucessfullly

curl -i http://localhost:9191/api/hello
Hello User!

Access secure resource with token

curl -i http://localhost:9191/api/secure

{"timestamp":1444985908768,"status":401,"error":"Unauthorized","message":"Access Denied","path":"/api/secure"}

Fetching refresh_token

curl -vu rajithapp:secret 'http://localhost:9191/api/oauth/token?username=admin&password=admin&grant_type=password'

{"access_token":"91202244-431f-444a-b053-7f50716f2012","token_type":"bearer","refresh_token":"e6f8624f-213d-4343-a971-980e83f734be","expires_in":1738,"scope":"read write"}

Fetching acess_token by submitting refresh_token

curl -vu rajithapp:secret 'http://localhost:9191/api/oauth/token?grant_type=refresh_token&refresh_token=<refresh_token>'

{"access_token":"821c99d4-2c9f-4990-b68d-18eacaff54b2","token_type":"bearer","refresh_token":"e6f8624f-213d-4343-a971-980e83f734be","expires_in":1799,"scope":"read write"}

Access secure resource sucessfully

curl -i -H "Authorization: Bearer <access_token>" http://localhost:9191/api/secure

Secure Hello!