OAuth token refresh question

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 07:51 AM
I am building my first integration (using REST and OAuth), and everything is working well, except that the OAuth token for the external system keeps expiring (it's set to 30 minutes).
I can refresh it manually by going to the REST Message, and using the Get Token UI Action, but obviously that isn't the real solution.
How can I refresh the token automatically (I am calling the REST Messages via business rule)?
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 08:01 AM
Hello,
Your script will need to validate if the auth token has expired and then automatically renew it.
Please refer to these posts covering the topic in different ways
https://community.servicenow.com/community?id=community_question&sys_id=c459e6a4db9ee30011762183ca96193e&view_source=searchResult
https://community.servicenow.com/community?id=community_question&sys_id=5b544769dbd8dbc01dcaf3231f961937&view_source=searchResult

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 08:36 AM
Thank you for the reply. Let me back up a bit, because I am starting to question my approach.
I need to integrate with Salesforce. My ServiceNow users do not have a Salesforce account, so I need to be able to use a service account to authenticate to Salesforce. I'd originally set up the Oauth provider using an Authorization Code grant type. This works great (the refresh issue non-withstanding).
However, the token is tied to my ServiceNow user.
Should I be approaching this differently? Since my ServiceNow users won't be able to log into Salesforce, should I be using a different grant type?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 09:00 AM
A generic SN ID would suffice who can authenticate on behalf of all users. You can setup a temp user using a SYS property and use this ID to access tokens.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2020 10:10 AM
Hi Tomko,
Did you find the solution for this. I have same the requirement, please let me know if you were successful with the oAuth intergration.