Postman to servicenow using OAuth 2.0

21121A3359
Tera Expert

Even I given Correct Client Id, and Client SecretI'm getting this 
What Should i need to do 

8 REPLIES 8

Hello @21121A3359, could you please change form-data to x-www-form-urlencoded and try? Also, under Authorization should be set to None.

 

Regards,

Nishant

Rabah2
ServiceNow Employee

Can you make sure your instance has the below property and is set to true

glide.oauth.inbound.client.credential.grant_type.enabled

If it is not there create it and set it to true then test again

https://www.servicenow.com/docs/r/zurich/platform-security/authentication/create-cc-sys-prop.html

Tanushree Maiti
Tera Patron

Hi @21121A3359 

 

401 is authentication error.

In Postman's OAuth 2.0 configuration, find the Client Authentication dropdown. 
  • Recommended: Try switching between "Send as Basic Auth header" and "Send client credentials in body".
  • ServiceNow typically expects credentials in the request body for the /oauth_token.do endpoint

 

2) In your Target system from where you've received Client ID and Secret, ensure the "Default Grant type" is set to "Client Credentials" and "OAuth Application User" as your Rest User profile with right level of API access/roles.

Refer: OAuth 2.0 Client Credentials works in Postman but not from ServiceNow-to-ServiceNow (401 error) 

 

3) 

Ensure your request is sent correctly if you are building the POST request manually:
  • Header: Content-Type: application/x-www-form-urlencoded.
  • Body: Ensure you are using x-www-form-urlencoded format, not raw JSON
  •  
Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Luiz Lucena
Mega Sage

Your error message is clear. 

It's missing the user to authenticate. 

 

It requires a user and password AND client ID and secret for OAuth 2.0.

 

In your Postman, in the authorization tab, you are going to set Auth Type: OAuth 2.0 and add all the required fields:
Grant type: Client Credentials
Access token URL: your instance URL/oauth_token.do
Client_ID
Client_secret
Client authentication: Send as basic auth header

In the Body tab (in Postman) you will add the username authorized to login to get the token, the password for that account, granty_type as password, the client ID and secret.

Once done, you will go back to the Authorization tab in Postman and click the Get New Access Token and then Use Token in the pop-up window.

Try that and let us know.