How to generate token/refresh token Oauth2 automatically ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2019 05:22 PM
Hello,
So I am currently integrating 2 servicenow instances and now I am trying to implement the OAuth2 authentification for the outbound and inbound REST messages.
Currently, I am able to generate the token manually from the REST message.
My question is if it is possible to automatize the token generation, possibly include it in the business rule, so the script would basically check if the token has expired and if it has it would use the refresh token to generate a new one and use it for authentication?
Many thanks,
Andrei
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2019 03:28 AM
Thank you for the advice.
How would the schedule workflow look like, what script would i have to include in order to automatize the token generation ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2019 07:17 AM
I am not sure a scheduled job would be the best approach because you could make network calls unnecessarily. If you want to go the "refresh" route then I think your idea of using a business rule would be the best approach, though I think you may potentially run into some "race conditions"/timing issues. Let us know how it works out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 02:08 AM
I was able to actually create business rule based on of the tokens are expired or not and if they are it updates the token and refreshes the expiry time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 02:50 PM
Hi Andrei,
could you please guide me,
1. How you check if tokens are expired ?
2. How do you refresh the token code ?
Thank you
dev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 02:38 AM
Hi,
Could you refresh the token automatically finally?