Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Securing REST API with Spring Security OAuth2 password flow

NotificationsYou must be signed in to change notification settings

satdrasing/spring-boot-oauth2-password-flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Securing REST API with Spring Security OAuth2 password flow

MinimalSpring Boot sample app.

Requirements

For building and running the application you need:

Running the application locally

There are several ways to run a Spring Boot application on your local machine. One way is to execute themain method in thecom.satendra.springbootoauth2passwordflow.SpringBootOauth2PasswordFlowApplication class from your IDE.

Alternatively you can use theSpring Boot Maven plugin like so:

mvn spring-boot:run

Usage example

1. Generate token
curl -X POST -u "trusted-client:trusted-secret" -d "grant_type=password&username=satendra&password=satendra1" http://localhost:8080/oauth/token{  "access_token":"1297a472-43d1-49f8-9615-cee0e1afaa44",  "token_type":"bearer",  "refresh_token":"b6681620-d142-404a-9af9-0adb1c55fe8d",  "expires_in":3466,  "scope":"read write"}
2. Wrong password
curl -X POST -u "trusted-client:trusted-secret" -d "grant_type=password&username=satendra&password=worngpassword" http://localhost:8080/oauth/token{  "error":"invalid_grant",  "error_description":"Bad credentials"}
3. Wrong client username or password
curl -X POST -u "wrongclient:trusted-secret" -d "grant_type=password&username=satendra&password=satendra1" http://localhost:8080/oauth/token{  "timestamp":"2019-04-26T18:28:14.872+0000",  "status":401,  "error":"Unauthorized",  "message":"Unauthorized",  "path":"/oauth/token"}

About

Securing REST API with Spring Security OAuth2 password flow

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp