OAuth for Scripted REST API(Inbound to Servicenow)

ojhagargi
Tera Contributor

I have enabled OAuth for Servicenow Scripted REST API, however my client wants to generate new Access token every time they hit "token" endpoint.

Do we have such provision in servicenow?

6 REPLIES 6

Murthy Ch
Giga Sage

Yes, ServiceNow can issue a new access token every time the client hits the /oauth_token.do endpoint as long as they use the client_credentials grant type. That’s standard behavior.

Thanks,
Murthy

ojhagargi
Tera Contributor

Hello @Murthy Ch ,

 

I did create an Application registry with client_credentials , but its giving me same token on multiple hit.
Any specific item to check?

I followed the below article: OAuth Inbound Authentication with ServiceNow: Client Credential Flow Using Postman - Support and Tro...

Ankur Bawiskar
Tera Patron
Tera Patron

@ojhagargi 

Usually access token lasts for 30mins, but if the access token is valid requested within that 30mins, it will give the same token.

After 30mins it will be a new token.

3rd party will have to use Refresh token to grab the access token until Refresh token expires.

Before the refresh token expires they need to generate the access + refresh token again.

Refresh token within ServiceNow expires after 100 days.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hello @Ankur Bawiskar , 

Thankyou for your response!

My client wants to generate new access token every time they hit SN's token generation API, is there any way to achieve that, since token refresh alone will be handled at AWS end(from their side) and there is a chance to miss the token refresh if the token expires between intervals. If the generated token is unique, then it will not expire prior to the interval.