OAuth2 token request returned 401
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I created an Application Registry type "Client Credentials" and am getting this error when I try to connect using the client ID and secret from my application:
401: {"error_description":"access_denied","error":"server_error"}. Check that the Client ID/Secret are still valid and the Application Registry is active.
I configured auth scopes: OAuth APIs, Table APIs, and Attachment APIs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Please verify the following:
Enable the Client Credentials grant type
Check the system property:
glide.oauth.inbound.client.credential.grant_type.enabledMake sure it is set to true and, importantly, create/update this property in the Global scope. A similar issue has been reported where the property was created in a scoped application, which caused authentication to fail.
Configure OAuth Application User
For the Client Credentials grant, ServiceNow needs an OAuth Application User. Add the OAuth Application User field to the OAuth Entity/Application Registry form through Form Design and select an appropriate active ServiceNow user. ServiceNow states that the authorization request is passed using this associated OAuth Application User.
Also verify that the selected user has the required roles/ACL access to the APIs you are trying to consume.
Verify the Application Registry
Make sure:
Application Registry is Active
Client ID is correct
Client Secret is correct and has not been regenerated
Grant type is Client Credentials
The OAuth Application User is populated
Review the OAuth scopes
The scopes should match the APIs that the external application needs. However, simply adding OAuth APIs, Table APIs, and Attachment APIs does not by itself guarantee access to the underlying tables. The OAuth scope controls the API access, while the associated OAuth Application User must also have the required permissions/ACLs.
Test the token endpoint directly
Use:
POST https://<instance>.service-now.com/oauth_token.do
with:
grant_type=client_credentials
client_id=<client_id>
client_secret=<client_secret>The Client Credentials flow should return an access token, which can then be used as:
Authorization: Bearer <access_token>
If you found this as helpful please accept the solution and mark it as helpful
Thanks,
Prajakta
