Client credentials flow

Let's start with the client credentials flow.

Our application needs to be up on port 7777, then we can use the following command line to get the token:

curl -s 442cf4015509eda9c03e5ca3aceef752:4f7ec648a48b9d3fa239b497f7b6b4d8019697bd@localhost:7777/oauth/token   -d grant_type=client_credentials  -d scope=trust | jq .

As we can see, this client ID and client secret are from the planes microservice. We did this configuration at the OAuth2AuthServer class. Let's remember the exact point:

....@Overridepublic void configure(ClientDetailsServiceConfigurer clients)throws Exception {  clients      .inMemory()      .withClient("ecommerce") // ecommerce microservice      .secret("9ecc8459ea5f39f9da55cb4d71a70b5d1e0f0b80") .authorizedGrantTypes( ...

Get Spring 5.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.