OAuth 2.0 getting access token issue on postman

Sreedhar M
Kilo Expert

I'm trying to generate the access/refresh tokens using postman.

I have given Get method and provided the instance url as https://xxxxxx.service-now.com/oauth_token.do and under headers section, provided all the required key value pairs, like client id, secret, username, password and grant type.

And when I hit Send button , getting the below error,

{

   "error_description": "access_denied",

   "error": "server_error"

}

please help me to get the tokens.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Sreedhar M 

I have written a blog for this

Please refer the same and do remember to mark it as helpful and also bookmark if that helps

OAuth 2.0 with Inbound REST

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

27 REPLIES 27

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

what is the http status code?

Is it 401 -> it means invalid user credentials

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar yes, I'm getting 401 Unauthorized error but the credentials are correct only. Because I'm able to generate the Access tokens using servicenow instance from Rest Message and able to test successfully. I was just trying through Postman and getting this issue.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Are you able to get the OAuth access token with the admin user session?

The ACL on the oauth_credential table might be causing this issue. Try adding a read ACL on the table and provide the role who needs this access to call and you should be able to test it.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

which role should I add to the ACL ? and the same role should I add to the user?

Hi,

If you are able to generate the token using admin user then issue is with the ACL.

The API user you are using has which role?

check the oauth_credential table level READ ACL and give that role which that user has

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader