This guide walks you through creating an OAuth 2.0 application profile in ServiceNow for use with NowAIKit.
- ServiceNow instance access (admin or equivalent permissions)
- Ability to create OAuth applications in ServiceNow
- Your ServiceNow instance URL (e.g.,
https://dev12345.service-now.com)
-
Log into your ServiceNow instance as an administrator
-
In the Filter Navigator (left sidebar), type:
oauth -
Click on System OAuth > Application Registry
-
Click the New button in the Application Registry
-
You'll see a prompt asking "What kind of OAuth application?"
-
Select Create an OAuth API endpoint for external clients
This option allows external applications (like NowAIKit) to authenticate to ServiceNow.
Fill in the following fields:
| Field | Value | Description |
|---|---|---|
| Name | NowAIKit |
Descriptive name for your OAuth app |
| Client ID | Auto-generated | Will be generated automatically (save this!) |
| Client Secret | Auto-generated | Will be generated automatically (save this!) |
| Active | ✅ Checked | Must be active to use |
| Field | Value | Description |
|---|---|---|
| Accessible from | All application scopes |
Recommended for MCP server access |
| Refresh Token Lifespan | 8640000 |
100 days (default) |
| Access Token Lifespan | 1800 |
30 minutes (default) |
Enable the following grant types:
- ✅ Password - Required for username/password authentication
- ✅ Refresh Token - Recommended for automatic token renewal
- ⬜ Client Credentials (optional)
- ⬜ Authorization Code (not needed for MCP server)
For NowAIKit, you can leave this blank or set to:
http://localhost:3000/callback
This is typically not used for password grant flows but may be required by some ServiceNow versions.
-
Click Submit to create the OAuth application
-
IMPORTANT: Copy the following values immediately:
- Client ID: A long UUID-like string (e.g.,
a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6) - Client Secret: A long secret string (e.g.,
z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4)
⚠️ Security Note: The Client Secret will only be shown once! Store it securely. - Client ID: A long UUID-like string (e.g.,
Add the OAuth credentials to your NowAIKit .env file:
# ServiceNow Instance
SERVICENOW_INSTANCE_URL=https://dev12345.service-now.com
# OAuth Authentication
SERVICENOW_AUTH_METHOD=oauth
SERVICENOW_CLIENT_ID=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
SERVICENOW_CLIENT_SECRET=z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4
SERVICENOW_USERNAME=your_username
SERVICENOW_PASSWORD=your_password
# Security Settings
WRITE_ENABLED=false
SCRIPTING_ENABLED=falseReplace:
dev12345.service-now.comwith your actual instance URLa1b2c3d4...with your actual Client IDz9y8x7w6...with your actual Client Secretyour_usernamewith your ServiceNow usernameyour_passwordwith your ServiceNow password
Test the OAuth endpoint directly:
curl -X POST "https://dev12345.service-now.com/oauth_token.do" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=password" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "username=YOUR_USERNAME" \
-d "password=YOUR_PASSWORD"Expected Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "dGhpc2lzYXJlZnJlc2h0b2tlbmV4YW1wbGU...",
"scope": "useraccount",
"token_type": "Bearer",
"expires_in": 1800
}Start NowAIKit and verify OAuth authentication:
cd nowaikit
npm run build
npm startCheck the logs for successful OAuth token acquisition:
[INFO] ServiceNow OAuth authentication successful
[INFO] Access token acquired, expires in 1800 seconds
Depending on your ServiceNow instance configuration, you may need to configure OAuth scopes:
| Scope | Description | MCP Server Needs |
|---|---|---|
useraccount |
User account access | ✅ Required |
admin |
Administrative access | ❌ Not needed (risky) |
read |
Read-only access | ✅ Recommended for read-only mode |
write |
Write access |
Most ServiceNow instances use the default useraccount scope which provides appropriate access for NowAIKit.
Cause: Client ID or Client Secret is incorrect
Solution:
- Double-check credentials in
.envfile - Verify no extra spaces or line breaks
- Re-generate OAuth application if needed
Cause: Username or password is incorrect, or user account is locked
Solution:
- Verify ServiceNow username and password
- Check if account is active in ServiceNow (System Security > Users)
- Ensure user has appropriate roles
Cause: OAuth application not properly configured
Solution:
- Verify "Password" grant type is enabled
- Check that OAuth application is Active
- Ensure "Accessible from" is set correctly
Cause: Insufficient permissions
Solution:
- Ensure you have
adminoroauth_adminrole - Contact your ServiceNow administrator
Cause: Short Access Token Lifespan
Solution:
- Navigate to your OAuth application
- Increase Access Token Lifespan (e.g., 3600 for 1 hour)
- Enable Refresh Token grant type for automatic renewal
Create a dedicated ServiceNow service account for NowAIKit:
Username: svc_mcp_server
Full Name: MCP Server Service Account
Email: mcp-server@yourcompany.com
Roles: itil, api_analytics_read (read-only recommended)
Benefits:
- Easier to audit MCP server actions
- Can be disabled without affecting users
- Scoped permissions (principle of least privilege)
- Rotate OAuth Client Secret every 90 days
- Update passwords according to your security policy
- Use environment variables, never hardcode credentials
- Set "Accessible from" to specific application scopes if possible
- Disable unused grant types
- Set appropriate token lifespans (don't make them too long)
ServiceNow provides OAuth monitoring:
- Navigate to System OAuth > Statistics
- Review token generation frequency
- Check for unusual access patterns
- Set up alerts for failed authentication attempts
Unless you specifically need write operations:
WRITE_ENABLED=false
SCRIPTING_ENABLED=false
ALLOW_ANY_TABLE=falseThis limits NowAIKit to read operations only, reducing security risk.
If OAuth is not available or causes issues, you can use Basic Authentication:
SERVICENOW_AUTH_METHOD=basic
SERVICENOW_BASIC_USERNAME=your_username
SERVICENOW_BASIC_PASSWORD=your_password- Better security (tokens expire, passwords don't)
- Automatic token refresh
- Easier credential rotation
- Better audit trails
After OAuth is configured:
- ✅ Test authentication with MCP server
- ✅ Configure Claude Desktop or Claude CLI with MCP server
- ✅ Test basic operations (e.g., get table schema)
- ✅ Review security settings and permissions
- ✅ Set up monitoring and logging
If you encounter issues:
- Check the Troubleshooting section above
- Review ServiceNow system logs: System Logs > System Log > All
- Open an issue on GitHub: https://github.com/aartiq/nowaikit/issues
- Consult your ServiceNow administrator
Last Updated: February 2026 ServiceNow Versions Tested: Xanadu, Yokohama, Zurich (latest three releases)
