Extending OAuthUtil API Script to include new parameters
This content was last updated in 2023. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 02:51 AM - edited 05-09-2023 02:55 AM
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'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 10:35 AM
Hi @benm3 ,
Here are a few things you can check:
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.
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.
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