Ref: Microsoft identity platform and the OAuth 2.0 client credentials flow
This scenario demonstrates Daemon application that calls web APIs
using Micronaut.
For example, this can be used in an SPA that calls a REST API on behalf of itself.
(Schematic from Azure documentation)
- Login to portal.azure.com
- Note down OAUTH_TENANT_ID
- Register api app in App Registration
- Display Name: OAuth_App
- Note down client_id from overview page as
OAUTH_CLIENT_ID
- Create and note down client_secret as
OAUTH_CLIENT_SECRET
- Set Application ID URI:
api://{{OAUTH_CLIENT_ID}}
- Add two app roles
- HelloRole with value=HelloRole
- WorlfRole with value=WorldRole
- Via "Manage application in local directory", enable "User assignment required?"
- Open this project in IntelliJ IDEA and update all
OAUTH_*
values in the run configuration - Register another app to represent a daemon SPA
- Display Name: SPA_App
- Note down client_id from overview page as
client_id
- Create and note down client_secret as
client_secret
- Add API permission for OAuth_App under My APIs; select both roles.
- Import
resources/MicronautAzureOAuth.postman_collection
in postman - Update all variables (
OAUTH_*
,client_id
andclient_secret
) in the Postman environment - Get bearer token using request POST-SP-BearerToken in Postman
- Run this project in Idea and check requests in Postman