- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2016 07:49 AM
First, I have created a OAuth Profile for Google Cloud in the Application Registry using the 'Connect to a third party OAuth Profile'. The Profile created is as follows.
I am using the OAuth Profile in the REST Messages to Various Calls such as Create VM,Turn Off Vm,Turn On VM etc., when I am using the OAuth Profile it shows the following message every time that 'OAuth Access or Refresh tokens are not available. Verify the OAuth configuration and click the 'Get OAuth Token' link below to request a new token.'
Everytime I query a REST message it shows this and I need to Click on Get OAuth Token to get the Token. The Validity of the token lasts for only an hour after that I need to refresh it again by clicking on the Get OAuth Token.
I need to know is there any way by Scripting or any other method to get the OAuth Token without Clicking the Get OAuth Token and also token lasts for a longer time.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2016 08:39 AM
Hi Aashish,
The key is you need to get an 'offline' token so it lasts as long as your refresh token lifespan indicates.
josh.nerius covered this on the 9-23-2016 edition of Live Coding Happy Hour. I had to implement it myself recently.
Watch this video. He starts somewhere around 40:00.
ServiceNow Live Coding Happy Hour for 2016-09-30 - OAuth Part 2 - YouTube
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 02:54 PM
Hi Sai,
The above code which I provided go generate Access Token using the Refresh Token. The initial step to get access token / token type e.t.c is manual but then you can run a schedule job (before the expiry time of Refresh Token) and keep updating your access token using the above code as an example. The code will change based on which application you are trying to automate. The above example I shared is for O-Auth integration with BOX application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 07:22 AM
Hi Rajeev,
I'm not able to automate the token. Please help me in this.
Thanks,
Sai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2017 12:29 PM
Hi Sai,
What application you are working on and what issue you facing. Please elaborate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2017 02:41 AM
Hi
I am able to generate the OAuth code by clicking on Get OAuthToken related link and the integration works fine - however this only works for admin users and doesnt work for non -admin users. For example when itil user tries to use this integrations, I receive following error:
com.glide.communications.ProcessingException: User Not Authenticated. OAuth token has expired or has not been retrieved.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2017 05:08 AM
The default for the OAuth token is only 24 hours. I suspect it is expiring prematurely. Josh explains how to address this (for Google anyway) in the video noted in the correct answer response.