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

Hi,

I would recommend 2 approaches

1) schedule job to refresh token and access token

OR

2) invoke the access token everytime you invoke the API

Regards
Ankur

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

@Ankur Bawiskar yes.. invoking API is automatically generating the Access token. If not invoking API, yes scheduled job is the right option. Thanks again. You are the man.

You are welcome.

I had faced some difficulty in generating/refreshing the token via scheduled job since the job would run with System user and the token had some issue during the API consumption.

Not much sure on that but some issue was there

Regards
Ankur

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

Somehow for me also schedule job not generating the access token, but job showing as ran.

I've another question, what happen when refresh token expires and we try invoking api? will this also generate refresh token or we should get the token through api again ?

Hi,

yes when you invoke the API it would everytime generate fresh access token if previous access token already expired.

Not much sure on the refresh token as haven't checked it

Regards
Ankur

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