Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
If OAuth application registry authorization URL contains extra query parameter then URL is formatting wrongly and throwing 404 error - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • If OAuth application registry authorization URL contains extra query parameter then URL is formatting wrongly and throwing 404 error
KB0786459

If OAuth application registry authorization URL contains extra query parameter then URL is formatting wrongly and throwing 404 error


1090 Views Last updated : Apr 26, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

If OAuth application registry authorization URL contains extra query parameter then URL is formatting wrongly with extra "?" mark in URL and throwing an error as 404 after we click on Get OAuth token in REST message  if you see the URL in the screenshot we can observer "?" mark after Authorize and after Service_now, here p=B2C_1_Service_now is extra query parameter in Authorization URL

Release

All

Cause

For example, your Authorization URL contains an extra query parameter as shown here "https://URL.domain.com/oauth2/v2.0/token?p=B2C_1_Service_Now" and when you click on Get OAuth Token in REST message request URL will get generated with extra "?" mark back to back which causes URL as invalid and throws 404 error as below, if you see the URL in the screenshot we can observer "?" mark after Authorize and after Service_now, here p=B2C_1_Service_now is extra query parameter in Authorization URL

 

 

Resolution

  • In order to resolve this issue, we need to remove that extra query parameter from Authorization URL and override by creating one script include which extends the OOB OAuthUtil script include as below.
var OAuthUtil1 = Class.create();
OAuthUtil1.prototype = Object.extendsObject(OAuthUtil, {
    preprocessAuthCode: function(requestParamMap) {
        requestParamMap.put("p", "B2C_1_Service_Now");
    },

	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) {
				if (param == 'id_token') {
					paramMap.put("access_token", tokenResponse[param].toString());
				}
				else {
					paramMap.put(param, tokenResponse[param].toString());
				}
            }
		}
    },

    type: 'OAuthUtil1'
});


*Once the script is created then we can refer this custom script on OAuth API script field which will be available in that particular application registry

 


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.