-
-
Save jmaxwell81/c73e31b16794794ebba3881be6efe47e 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