Skip to main content

ServiceNow: Generate Token

Register the app

  1. Login into ServiceNow Portal.
  2. Navigate to System oAuth  Application Registry.

alt text

  1. Click New. The OAuth application page appears.
  2. Choose Create an OAuth API endpoint for external clients.

alt text

  1. Provide valid values of Name, Redirect URL, etc.

alt text

tip

Client Secret is automatically generated after you click Submit button.

  1. Click Submit.

Generate Authorization Code

  1. When the OAuth application is ready to use, we need to generate the authorization_code. To generate the code, the user must send the request call on the browser with the following URL: https://<serviceNow_instanceURL>/oauth_auth.do?response_type=code&redirect_uri=<redirect_url>&client_id=<client_id>&state=active For example,

https://dev75906.service-now.com/oauth_auth.do?response_type=code&redirect_uri=https://www.google.com&client_id=030ee2c7f550a&state=active

  1. The user is redirected to the oauth login page: /oauth_login.do
  2. Enter valid credentials in Username and Password field.

alt text

  1. After the login is successful, the user will get the prompt as mentioned in the screenshot below, user needs to allow this by clicking on the Allow.

alt text

  1. Code will appear in the browser search bar, copy the code.

alt text

alt text

Generate Refresh Token using Authorization Code

  1. Now, will use the POSTMAN client, to generate the refresh token. As mentioned in the following steps:
POST https://.service-now.com/oauth_token.do
Body: x-www-form-urlencoded
grant_type: authorization_code
code: generated in step 3.e
redirect_uri: uri provided at the time of app creation.
client_id: generated at the time of app creation.
client_secret: generated at the time of app creation.
  1. Postman request will look like:

alt text

  1. Copy the Refresh Token.