ServiceNow OAuth Authorization Code Grant with Spring Security OAuth2 Client: User Context and Audit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello Community,
We are evaluating an integration between a Java Spring application and ServiceNow using OAuth 2.0 Authorization Code Grant.
The objective is to allow an individually authenticated ServiceNow user to initiate REST API transactions through an external application while preserving the user's ServiceNow authorization context and native audit attribution.
Our proposed implementation uses:
- Spring Security OAuth2 Client
- ServiceNow as the OAuth authorization server and REST API resource server
- OAuth 2.0 Authorization Code Grant
- Enterprise SSO for interactive user authentication
- Individual-user OAuth access tokens
- ServiceNow roles and ACLs for API authorization
We have reviewed the official ServiceNow Authorization Code Grant Workflow.
We would appreciate hearing from anyone who has implemented a similar integration.
Specifically:
Spring Security integration: Have you successfully used Spring Security OAuth2 Client with ServiceNow's inbound Authorization Code Grant?
OAuth versus OIDC: Did you configure ServiceNow as a standard OAuth 2.0 provider using its authorization and token endpoints, without requiring OpenID Connect discovery or ID tokens?
PKCE: Have you implemented PKCE with a confidential Spring Security OAuth client against ServiceNow? Were any additional configuration steps necessary?
User authorization: When an access token obtained through the individual-user Authorization Code flow is used for REST API operations, does ServiceNow evaluate the authenticated user's roles and ACLs as expected?
Native audit attribution: For REST API record creation and updates, do sys_created_by, sys_updated_by, and the native audit/history records reflect the authenticated user?
Implementation considerations: Were there any unexpected issues with callback configuration, refresh-token handling, user-session association, or authorization-code processing?
We understand that Authorization Code requires interactive user authorization and are not attempting to bypass that requirement.
We are interested in standards-based, supported implementations rather than custom authentication or user-impersonation mechanisms.
Any examples, documentation references, or lessons learned would be appreciated.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Adding one observation from the ServiceNow Australia release configuration.
When configuring the OAuth Authorization Code grant, the "This is a public client" option displays the following tooltip:
"When you enable this option, the Client secret validation is skipped and the PKCE flow is used."
This appears to distinguish between:
- Confidential clients: Client-secret authentication.
- Public clients: PKCE without client-secret validation.
However, current OAuth security best practices recommend PKCE as an additional protection for confidential clients as well.
This raises a specific implementation question:
Does ServiceNow support simultaneous client-secret authentication and PKCE (S256) validation for a confidential OAuth client using Authorization Code grant?
More specifically:
- Can a confidential client send code_challenge and code_challenge_method=S256 while retaining client-secret authentication?
- Will ServiceNow validate the corresponding code_verifier during the token exchange?
- Is there a supported configuration to require PKCE without enabling "This is a public client"?
- If this combination is unsupported, is that an intentional limitation of the current implementation?
We're using Java Spring Security OAuth2 Client and would prefer to retain confidential-client authentication while adding PKCE as defense in depth.
Any confirmation from ServiceNow engineering or community members who have tested this combination would be greatly appreciated.