Skip to content

odhekar/MicronautAzureOAuth

Repository files navigation

Micronaut Azure OAuth 2.0 Client Credentials Flow

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.

From: https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-daemon-overview
(Schematic from Azure documentation)

Steps

  1. Login to portal.azure.com
  2. Note down OAUTH_TENANT_ID
  3. Register api app in App Registration
    1. Display Name: OAuth_App
    2. Note down client_id from overview page as OAUTH_CLIENT_ID
    3. Create and note down client_secret as OAUTH_CLIENT_SECRET
    4. Set Application ID URI: api://{{OAUTH_CLIENT_ID}}
    5. Add two app roles
      1. HelloRole with value=HelloRole
      2. WorlfRole with value=WorldRole
    6. Via "Manage application in local directory", enable "User assignment required?"
  4. Open this project in IntelliJ IDEA and update all OAUTH_* values in the run configuration
  5. Register another app to represent a daemon SPA
    1. Display Name: SPA_App
    2. Note down client_id from overview page as client_id
    3. Create and note down client_secret as client_secret
    4. Add API permission for OAuth_App under My APIs; select both roles.
  6. Import resources/MicronautAzureOAuth.postman_collection in postman
  7. Update all variables (OAUTH_*, client_id and client_secret) in the Postman environment
  8. Get bearer token using request POST-SP-BearerToken in Postman
  9. Run this project in Idea and check requests in Postman

Feature security-jwt documentation

Feature security-oauth2 documentation

Feature http-client documentation

About

Micronaut Azure OAuth flow for a REST api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages