Servicenow Oauth token API giving 401 access denied

Shrinil
Tera Contributor

I use this API <instance_name>.service-now.com/oauth_token.do with grant_type as refresh_token.

This API is used in order to refresh the access_token every time it expires.

 

I was of the opinion that if this API results in 401 Unauthorized access with body as 

{
    "error_description": "access_denied",
    "error": "server_error"
}

that means that the refresh token has expired and user has to use this API with grant_type as password.

 

But recently I have found out that on making multiple calls to refresh the token some fail with this error, and next time the same call passes.

 

Can someone help me identify what could be the issue here? or in what case can I get 401 unauthorised and on next call I get 200 as response?

 

7 REPLIES 7

yes u can try using ur user id and pass under authentication

ah-khalid
Tera Contributor

I managed to solve this issue, it turns out that the "grant_type " contains a whitespace.

Mahesh_Krishnan
Giga Guru

I am experiencing the same issue with no changes to the header values; it works sometimes and other times gives the "Access Denied" error