Error when trying to generate Oauth token
Options
- 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:
- Labels:
-
Integrations
-
Scripting and Coding
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 02:32 AM
Added a comment in https://community.servicenow.com/community?id=community_question&sys_id=047c9ac3dbb97340feb1a851ca96.... Please check