REST OAuth example

reference brazil Updated Sep 10, 2026 1 min read r_RESTOAuthExample.md
Raw file servicenow.com

This example shows how to authenticate an inbound REST request using OAuth.

In this example, the OAuth application registry entry has a client ID of example_client_id and a client secret of example_client_secret. Replace these values, and the user name and password shown in the examples, with the values for your own OAuth application and REST user.

Getting an access token

To request an access token, send a POST request to the oauth_token.do endpoint of your instance. This example uses the password grant type and passes the client ID, client secret, and the credentials of the user the token is issued for. Replace the placeholder values with your own.

Shell
curl -d "grant_type=password&client_id=example_client_id&client_secret=example_client_secret&username=example_user&password=example_password" https://<instance>.service-now.com/oauth_token.do

Sample token response

If the request succeeds, the instance returns a JSON response like the following. The access_token value is the token you pass in the Authorization header of subsequent requests. The refresh_token value can be used to request a new access token after the current one expires. The expires_in value is the number of seconds until the access token expires. The token values shown here are placeholders, not real tokens.

JSON
{  "scope": "useraccount",  "token_type": "Bearer",  "expires_in": 1799,  "refresh_token": "example_refresh_token_value",  "access_token": "example_access_token_value"}

REST request with OAuth token

To call a REST API with the token, include it in the Authorization header with the Bearer prefix. This example uses the access token from the previous response to retrieve records from the Incident table (Table API). Replace example_access_token_value with the access_token value returned for your request.

Shell
curl -H "Accept: application/json" -H "Authorization: Bearer example_access_token_value" "https://<instance>.service-now.com/api/now/table/incident"

Parent Topic:Enable OAuth with inbound REST

Search documentation
Search document titles and file paths on the brazil branch