Last active
February 28, 2021 19:21
-
-
Save jnerius/1d291b7847574be2f62d926f512bfaa1 to your computer and use it in GitHub Desktop.
ServiceNow OAuth Handler Script Include for processing Bit.ly OAuth Tokens
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var OAuthBitlyHandler = Class.create(); | |
OAuthBitlyHandler.prototype = Object.extendsObject(OAuthUtil, { | |
initialize: function() { | |
}, | |
interceptRequestParameters : function(requestParamMap) { | |
// Add/Modify request parameters if needed | |
this.preprocessAccessToken(requestParamMap); | |
}, | |
parseTokenResponse: function(accessTokenResponse) { | |
this.postprocessAccessToken(accessTokenResponse); | |
}, | |
preprocessAuthCode: function(requestParamMap) { | |
}, | |
preprocessAccessToken: function(requestParamMap) { | |
gs.info('preprocessing'); | |
}, | |
postprocessAccessToken: function(accessTokenResponse) { | |
var contentType = accessTokenResponse.getContentType(); | |
var contentBody = accessTokenResponse.getBody(); | |
var paramMap = accessTokenResponse.getparameters(); | |
var params = contentBody.split('&'); | |
var parts; | |
params.forEach(function(param) { | |
parts = param.split('='); | |
gs.info('key=' + parts[0] + ', value=' + parts[1]); | |
paramMap.put(parts[0], parts[1]); | |
}); | |
}, | |
type: 'OAuthBitlyHandler' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment