Giter Site home page Giter Site logo

demo-oauth2-spring-security's Introduction

demo-oauth2-spring-security

A simple Password Flow demo with Spring Security OAuth 2

Testing

You can use Postman to test it.

First you'll need to get the access_token

  1. Create a POST request for the address: http://localhost:8080/oauth/token

  2. You have to pass Basic Auth too, this is the client credentials, not the user. In this example the username is "client" and password "clientpassword" (without quotes).

The authorization header will looks like: Authorization : Basic Y2xpZW50OmNsaWVudHBhc3N3b3Jk

  1. Set the Content-Type header to application/x-www-form-urlencoded

alt text

  1. Set the body

You'll have to choose x-www-form-urlencoded and set the values:

client_id client

username user

password user

grant_type password

alt text

When you hit the send button, you'll get something like that:

{
  "access_token": "bd999429-898b-4201-908e-40e846ec0105",
  "token_type": "bearer",
  "expires_in": 3599,
  "scope": "read write"
}

Calling the API

Now you are able to call the API using the access token

  1. Create a GET request in Postman with the URL http://localhost:8080/products

  2. Set the Authorization header with Bearer

Key: Authorization

Value: Bearer bd999429-898b-4201-908e-40e846ec0105

That's all! When you hit the Send button, you'll receive:

[
  {
    "name": "Mug for Coffee",
    "value": 12.99
  },
  {
    "name": "Coffee cup",
    "value": 4.21
  }
]

alt text

demo-oauth2-spring-security's People

Contributors

normandesjr avatar

Watchers

Theo Andersen Carton avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.