Skip to content

Instantly share code, notes, and snippets.

@jnerius
Last active February 28, 2021 19:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jnerius/1d291b7847574be2f62d926f512bfaa1 to your computer and use it in GitHub Desktop.
Save jnerius/1d291b7847574be2f62d926f512bfaa1 to your computer and use it in GitHub Desktop.
ServiceNow OAuth Handler Script Include for processing Bit.ly OAuth Tokens
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