Access token in case of client credentials grant type Oauth?

Kiran Kumar 76
Tera Expert

Hi

 

i am trying to integrate outbound rest with third party and recieved client secret and ID

 

i tested Get token through outbound rest api created and i am able to check the message token successful

 

but it says will be expired in an hour

 

Question :

In case of client credentials grant type ,how can we handle token without expiring ? or get new access token if expired

i am using script in business rule to call the API

3 REPLIES 3

KevinBellardine
Kilo Sage

Hey @Kiran Kumar 76 

 

Try looking at these two links and see if they help. You'll probably have to script a scheduled job to refresh the token every 50 minutes.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0791131

 

https://www.servicenow.com/community/developer-blog/rest-calls-where-seperate-auth-token-must-be-req...

 

Thanks @KevinBellardine 

 

can you please help me here in understanding below script from link

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0791131

 

var requestor_context = 'test'; //what value goes in here
var requestor_id = 'abc@xyz.com';//what value goes in here

var params = {grant_type:"password", username:'admin', password:'pwd', oauth_requestor_context:requestor_context, oauth_requestor:requestor_id, oauth_provider_profile:oauth_profile_id}; //Please update in case of client credentials how this line needs to be modified

Hey @Kiran Kumar 76 , 

 

Did you find any solution for getting access token automatically. I'm facing the same issue for Grant type Client Credentials. Help will be appreciated. Thanks