ServiceNow: Generate Token
Register the app
- Login into ServiceNow Portal.
- Navigate to System oAuth  Application Registry.

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

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

tip
Client Secret is automatically generated after you click Submit button.
- Click Submit.
Generate Authorization Code
- 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=activeFor example,
- The user is redirected to the oauth login page: /oauth_login.do
- Enter valid credentials in Username and Password field.

- 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.

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


Generate Refresh Token using Authorization Code
- 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.
- Postman request will look like:

- Copy the Refresh Token.