advancedScenario Questions

Scenario 6: A batch job needs to call an internal microservice API every night with no user involved. Which OAuth2 grant type fits, and how would you configure the resource server?

Client Credentials grant — the batch job authenticates as itself using its own client_id/client_secret, receiving an access token that represents the SERVICE, not a user. The resource server is configured identically to any other OAuth2 resource server (validating the JWT via JWKS or introspection), since it doesn't need to distinguish machine callers from user-driven ones at the token-validation layer.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Scenario 7: Users complain they're randomly logged out when your app is deployed across three load-balanced server instances using traditional session-based authentication. What's happening, and how do you fix it?← Back to all Spring Security questions