Name

global.OAuthUtil

Description

//* Dont edit this script include. Best practise Extend this script include and override the functions like shown in sample code. // Use the Script include to add or update headers, query parameters, endpoint URLs in oauth flow. //* sample script below //* var OAuthCustomUtil = Class.create(); OAuthCustomUtil.prototype = Object.extendsObject(OAuthUtil, { preprocessAuthCode function(requestParamMap) { this.oauthContext.setAuthorizationEndpoint( https //accounts.google.com/o/oauth2/v2/auth ); this.oauthContext.addHeader( Content-Type , application/json ); var profGr = this.oauthContext.getOAuthProfile(); gs.info(profGr.getValue( name )); }, preprocessAccessToken function(requestParamMap) { this.oauthContext.addHeader( Content-Type , application/json ); this.oauthContext.addQueryParameter( name , jackson ); gs.info(this.oauthContext.getQueryParameter( name )); gs.info(this.oauthContext.getHeader( Content-Type )); this.oauthContext.setTokenEndpoint( https //oauth2.googleapis.com/token ); var profGr = this.oauthContext.getOAuthProfile(); gs.info(profGr.getValue( grant_type )); }, type OAuthCustomUtil });

Script

//* Dont edit this script include. Best practise: Extend this script include and override the functions. 
var OAuthUtil = Class.create();
OAuthUtil.prototype = {
  initialize: function(oauthContext) {
  	this.oauthContext = oauthContext;
  },
  
  interceptRequestParameters : function(requestParamMap) {
  	// Add/Modify request parameters if needed
  	this.preprocessAccessToken(requestParamMap);
  },
  
  parseTokenResponse: function(accessTokenResponse) {
  	this.postprocessAccessToken(accessTokenResponse);
  },
  
  preprocessAuthCode: function(requestParamMap) {
  },
  
  preprocessAccessToken: function(requestParamMap) {
  },
  
  postprocessAccessToken: function(accessTokenResponse) {
  	var contentType = accessTokenResponse.getContentType();
  	if (contentType && contentType.indexOf('application/json') != -1) {
  		var tokenResponse = (new global.JSON()).decode(accessTokenResponse.getBody());
  		var paramMap = accessTokenResponse.getparameters();
  		for (param in tokenResponse)
  			paramMap.put(param, tokenResponse[param].toString());
  	}
  },
  
  type: 'OAuthUtil'
};

Sys ID

3e3a3a11c333210016194ffe5bba8f70

Offical Documentation

Official Docs: