OAuth (Open Authorization) is a secure way to allow applications to access resources on behalf of a user without exposing their credentials. This guide will walk you through setting up OAuth for ServiceNow Table API and configuring Postman to use OAuth tokens for making API requests. As a mockup feel free to use use our project in Postman
Prerequisites:
ServiceNow Instance with admin
Postman installed on your system or cloud - depends if the instance is available internally or public
Administrator access to ServiceNow for setting up OAuth.
Step 1: Create an OAuth Application Registry in ServiceNow
Log into your ServiceNow instance as an admin.
Navigate to System OAuth > Application Registry.
Click on New to create a new OAuth application.
Select Create an OAuth API endpoint for external clients.
Configure the OAuth Application:
Name: Give your application a meaningful name (e.g., Postman OAuth).
Client ID: A unique identifier for your application. You can leave this blank to auto-generate.
Client Secret: A secret known only to the application and the authorization server. Click the lock icon to generate one.
Redirect URL: This is the callback URL where the authorization code will be sent. For Postman, use https://oauth.pstmn.io/v1/callback.
Save the record and note down the Client ID and Client Secret.
Step 2: Assign Roles to the OAuth Application
Navigate to System OAuth > Application Registry and open the OAuth application you created.
Scroll down to the Application Roles related list and click on New.
Add the necessary roles that your application will need to access ServiceNow resources, such as rest_api_explorer, snc_internal or any specific roles required for accessing target tables.
Step 3: Get an OAuth Token Using Postman
Open Postman and create a new request.
Go to the Authorization tab.
Select OAuth 2.0 as the type.
Click on Get New Access Token.
Configure the Token Settings:
Token Name: A name for your token (e.g., ServiceNow Token).
Grant Type: Authorization Code.
Callback URL: https://oauth.pstmn.io/v1/callback.
Auth URL: https://<instance_name>.service-now.com/oauth_auth.do.
Access Token URL: https://<instance_name>.service-now.com/oauth_token.do.
Client ID: The Client ID from your ServiceNow OAuth application.
Client Secret: The Client Secret from your ServiceNow OAuth application.
Scope: Leave this blank or specify any scopes required by your application.
State: A unique identifier to maintain the state between the request and callback.
Click on Request Token. You will be redirected to the ServiceNow login page. Log in with your ServiceNow credentials and authorize the application. Postman will automatically handle the callback and fetch the access token.
Step 4: Use the OAuth Token in Postman Requests
In the Authorization tab of your Postman request, select OAuth 2.0 as the type.
Use the token you obtained in the previous step. You can select it from the dropdown menu in the Available Tokens section.
Step 5: Make API Requests Using OAuth Token
Now, you can make API requests to the ServiceNow Table API using the OAuth token.
Example: Get Records
Create a new request in Postman.
Set the request type to GET.
Use the following URL format: plaintext
Copy code https://<instance_name>.service-now.com/api/now/table/<table_name>?sysparm_query=<query>
In the Authorization tab, select OAuth 2.0 and ensure your token is selected.
Send the request.
Summary
If you have any questions or run into issues reach us out for further assistance. Also we have own Table API project free to share to so you don't have to reinvent the wheel. STREYDA's workspace
Commentaires