We are getting audience in addQueryParameter('audience','unique id '); No idea how we are getting ?

J P Rohini
Tera Contributor

We are getting audience in addQueryParameter('audience','unique id '); No idea how we are getting?

addQueryParameter data we are storing in the application registry.

Kindly help me to resolve this puzzles.

3 REPLIES 3

Ana39
Tera Expert

 

Most likely the audience value is coming automatically from the OAuth/Application Registry configuration, not from addQueryParameter() itself.

Check:

  • System OAuth > Application Registry
  • Connection & Credential Alias
  • OAuth Entity Profile

Search globally for:

 

 
audience

Very commonly, ServiceNow injects it automatically for OAuth/JWT flows (Azure, Okta, etc.).

Also check the outbound REST log to see the final generated request.

pavani_paluri
Kilo Sage

Hi @J P Rohini ,

 

Can you Please share more context here or a script snippet.

 

 

Tanushree Maiti
Mega Patron

Hi @J P Rohini 

 

1. Check if any rest message you have query parameter where you have passed Audience

Refer: KB2524284 OAuth Authentication Not Supported with 'Audience' as Parameter 

 

If yes, remove that from there. As per KB follow this workaround:

Below is a custom workaround,

1. Extend the OAuthUtil Script Include by creating a new Script Include that extends the out-of-the-box OAuthUtil Script Include. 

2. Override the interceptRequestParameters function in the new Script Include.

 3. Add the custom 'audience' parameter inside the overridden interceptRequestParameters function.

4. Implement the proposed approach in the system to include the 'audience' parameter in the request body.

Example implementation:

var OauthCustomUtil = Class.create();
OauthCustomUtil.prototype = Object.extendsObject(OAuthUtil, {
interceptRequestParameters: function(requestParamMap) {
// Add the 'audience' parameter
requestParamMap.put('audience', 'write_URL');

// Call the parent method to ensure other parameters are handled
this.preprocessAccessToken(requestParamMap);
},
type: 'OauthCustomUtil'
});

Since it is a work-around, I would strongly recommend validating it in a lower instance first. Please also avoid modifying the out-of-the-box Script Include directly.

 

2.In modern ServiceNow, Audience is primarily defined as user criteria to control which users see specific UI Builder pages . Refer: Add an audience to your UI Builder page 

 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: