- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 05:51 AM - edited 02-13-2025 05:56 AM
When I click on Get OAuth token, I am getting OAuth flow successful and seeing access token in the OAuth Credentials but when I did same by going into the get token http method and testing the connection I am again getting the 401 error. I am not sure why this is happening?
If I want to leverage the access token produced by rest message how I need to get it for furthermore actions as I need to pass it as a header to make outbound call?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 06:10 AM
Create an OAuth Profile:
Navigate to: System OAuth > Application Registry. If you haven’t already created an OAuth Profile, you need to do so. This profile will store the OAuth credentials, such as the Client ID, Client Secret, and other authentication details.
OAuth provider details. (this info you can see when you going to create OAuth application registry)
- Name: A unique name.
- Client ID: Client ID of application registered in third-party OAuth server.
- Client Secret: Client secret of application registered in third-party OAuth server.
- Refresh Token Lifespan: Time in seconds the Refresh Token will be valid.
- Authorization URL: OAuth Server's auth code flow endpoint. Required only for Authorization Code grant type.
- Token URL: OAuth Server's token endpoint.
- Token Revocation URL: OAuth Server's token revocation endpoint.
- Redirect URL: OAuth callback endpoint. Leave it empty for auto-generation.
Attach the OAuth Profile to the REST Message:
Navigate to: System Web Services > Outbound > REST Message.
Either create a new REST Message or edit an existing one.
In the Authentication tab, under OAuth 2.0, select the OAuth Profile you created earlier. This links the REST message to the OAuth Profile, which will automatically handle token management for you.
Token Management: ServiceNow will automatically fetch, refresh, and append the access token to the Authorization header for all REST API calls made using this REST Message.
Using the REST Message in Scripts (Flow/BR/Script Include/Sjob): Once the OAuth Profile is linked to the REST Message, you can simply call the REST message from a Flow, Business Rule (BR), Script Include, or Scheduled Job.
You do not need to manually pass the Authorization header in your API calls anymore.
Also you can refer following links for same :
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0693451
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2025 01:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 10:04 PM
No, I haven't added. Do I need to send authorization header when I am calling REST Message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 10:18 PM
I believe when you use Test Run it's not fetching the correct credentials and hence unable to get access token
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
02-17-2025 02:44 AM
I am able to get the access token however when I click on the test in http method, I am getting 403 with message {"error":{"code":"0x80072560","message":"The user is not a member of the organization."}}