Extending OAuthUtil API Script to include new parameters

benm3
Mega Guru

Hi,

 

I have extended the ootb 'OAuthUtil' script include as I need to pass in a few additional parameters to get an OAuth token, however, I do not think the parameters are ever being set or the script include is being accessed? I am using the ui action ' Get OAuth Token' on the rest message to retrieve the OAuth token. I am not sure if I need to add 'OAuth Entity Profile Scopes' on the OAuth Entity Profile record or I am missing anything else? If anyone could give us some guidance it would be appreciated. 

 

I have attached pictures of my rest message and application registry record. 

 

Here is the code within the extended script include:

 

var OAuthComplianceCommisionsUtils = Class.create();
OAuthComplianceCommisionsUtils.prototype = Object.extendsObject(global.OAuthUtil, {
	
	interceptRequestParameters : function(requestParamMap) {
		gs.info("here ben")
		// Add/Modify request parameters if needed
		requestParamMap.put('response_type','code');
		requestParamMap.put('scope','data.records:read');
		requestParamMap.put('state','Jt8WzfnT7dSbXn2xL1dY.mJq3-UvN4Kz0oGcRbH6pEjViI9Xy_OgZAkCs5lPuehr');
		requestParamMap.put('code_challenge','w1q3qECN6T2g6bN8ncUqKN6KLvCZ4uV7l-BP6oWGG7w');
		requestParamMap.put('code_challenge_method','S246');
		this.preprocessAccessToken(requestParamMap);
	},
	
	type: 'OAuthComplianceCommisionsUtils'
});

 

 

1 REPLY 1

Ratnakar7
Mega Sage
Mega Sage

Hi @benm3 ,

 

Here are a few things you can check:

  1. Check if the extended script include is being used: Make sure that the extended script include is being called instead of the OOTB OAuthUtil script include. You can check this by adding a log statement at the beginning of the 'interceptRequestParameters' function.

  2. Check if the UI action is using the correct script include: In the UI action, make sure that the 'Script Include' field is set to the name of your extended script include.

  3. Check if the OAuth Entity Profile Scopes are set correctly: Make sure that the scopes that you have added in the 'interceptRequestParameters' function are added to the OAuth Entity Profile record.

Thanks,

Ratnakar