i created a oauth profile to connect to a third party oauth provider - invalid client credentials
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 09:36 PM
Hi,
I have created an POST method to get the token from the server.Prviously, i have used No Authentication, with the client id client secret and grant_type passed in the Content of Outbound Rest Message.
Now, I want to use system property to store the endpoint, clientid, client secret and grant type in a sys_property and use that in the script include.
I tried to create an oauth profile, but it is giving me Invalid client credentials but i tried to test it using postman, it is working.
So, tell me how can i use No authentication and store the details in sys_property.
Below is the implementation done by me,
As i said I have one outbound rest message which has the endpoint and inside that i have created one POST message with the endpoint stored in ${x_abc.token.endpoint} and then in the same post method i have HTTP parameters and in the content i have :
client_id =${x_abc.icu_token_client_id}&client_secret=${x_abc.icu_token_client_secret}&grant_type=client_credentials
So, for this i have created 3 system properties in sys_properties table and in the UI action, i have called them sing below is the function to get the access token,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 10:04 PM
so you are consuming 3rd party API with OAuth details and trying to get token
You can use script to obtain the refresh and access token from script, script will vary based on grant type somewhat
refer below links
OAuth2.0: Get new Access Token from existing Refresh Token
How to Setup OAuth2 authentication for outbound RESTMessageV2 integrations
OAuth : Script to Automate Token Request
How to generate the access token once it is expired from Business Rule?
How to get Auth Token using script when grant type is Authorization code
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 10:13 PM
Hi,
I am not using oauth 2.0..I am using no authentication.Please tell me for above sceanrio using sys_properties.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 10:29 PM
then better to check with 3rd party on how to consume their endpoint.
They should have some documentation on how to do
how are you doing it in Postman?
Do similar thing in ServiceNow
Please share postman screenshot where it worked
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 02:47 AM
We are directly hitting the endpoint using no authentication and passing the clientid,client secret and grant ype in the content.
But the requirement is the endpoint, client id and client secret needs to be stored in a system property.
I have checked the configurations, code, still it is giving me error 401.