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

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Shrinil ,

 

Can you check below thread 

https://www.servicenow.com/community/developer-forum/get-oauth-token-gives-http-error-401-unauthoriz... 

 

Regards,

Gunjan Kiratkar


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Vikram Gupta
Tera Contributor

@Shrinil  did you get solution for the problem

g k1
Tera Guru

Its authentication issue, check id and password you are providing

ah-khalid
Tera Contributor

I'm receiving this error although I can access the instance using the same credentials with https://{instance-id}.service-now.com/login.do