Script to generate token using O Auth profile

Riya Verma
Kilo Sage
Kilo Sage

Hi Team, 

 

I have requirement to set O auth integration with other URL. I have created application registries providing the client id, client secret and token URL for same, and had O auth profile generated to above registry. 

application registry.pngO Auth profile .png

Then, I have created outbound rest message created providing the end point and selecting O auth profile generated. When we click get O Auth token UI action. Access token is getting generated successfully with expiry of 1 hour. 

 

MY requirement is to generate this access token every time whenever we are calling rest message V2 from BR. I have tried the below community blog but it's not working for me.

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

 

 

can someone please help me on how to generate the Access token for every call.

 

Regards,

Riya Verma.

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Riya Verma 

it seems you are in scoped app

Any scope related error you are getting?

check this link

Script to retrieve Access and Refresh tokens using GlideOAuthClient libraries 

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Riya Verma 

it seems you are in scoped app

Any scope related error you are getting?

check this link

Script to retrieve Access and Refresh tokens using GlideOAuthClient libraries 

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

Thank you @Ankur Bawiskar , Your provided Link worked out for me. 

 

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma