Skip to content

goelprateek/spring-rest-service-oauth

 
 

Repository files navigation

spring-rest-service-oauth

Build and Run

Build the app:

./gradlew clean build

Run the app:

java -jar build/libs/spring-rest-service-oauth-0.1.0.jar

Usage

Request OAuth authorization:

curl -X POST -vu clientapp:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=password&username=user&grant_type=password&scope=read%2Cwrite&client_secret=123456&client_id=clientapp"

A successful authorization results in the following response:

{"access_token":"ff16372e-38a7-4e29-88c2-1fb92897f558","token_type":"bearer","expires_in":43199,"scope":"read write"}

Use the access_token returned in the previous request to make the authorized request to the protected endpoint:

curl http://localhost:8080/greeting -H "Authorization: Bearer <INSERT TOKEN>"

If the request is successful, you will see the following:

{"id":1,"content":"Hello, World!"}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%