Error when trying to generate Oauth token
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2019 03:32 PM
Hello,
I am sometimes receiving the following error when trying to get a new Oauth Token via ScriptL
"
org.apache.commons.httpclient.HttpException: CertPathValidatorException
Invalid null response.: no thrown error
OAuthProblemException{error='Invalid null response.', description='', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}}
*** Script: [DEBUG] null // access token
*** Script: [DEBUG] 0 // expiry time
*** Script: [DEBUG] null // refresh token
"
The script that I am using is:
"
var oAuthClient = new sn_auth.GlideOAuthClient();
var params = {grant_type:"password", username:'username', password:'password'};
var json = new global.JSON();
var text = json.encode(params);
var tokenResponse = oAuthClient.requestToken('OAuth_Final_Client', text);
var token = tokenResponse.getToken();
var access_token = token.getAccessToken();
var token_expires = token.getExpiresIn();
var refresh_token = token.getRefreshToken();
gs.debug(access_token);
gs.debug(token_expires);
gs.debug(refresh_token);
"
The weird thing is that sometimes it works, sometimes it does not, seems to be very inconsistent and random when it wants to work.
Any ideas ?
Thank you !
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2019 09:19 PM
Hi Andrei,
Did you notice any pattern when it doesn't work?
like from few users session it works and from others it doesn't
check the below links:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 02:10 AM
Unfortunately no patterns, not sure if it is a problem with the Oauth provider/client or with the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 01:29 AM
Not sure about this scenario. I created an Outbound REST Message for generating OAuth token and is working without any failure.
Please let me know if you need help in generating token via Outbound Rest Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 02:00 AM
Hello,
I did not consider thap option but could be a good idea.
Can you please let me know how you set up the REST Message and how it handles the access/refresh tokens lifepsan ?
Thank you for the help !