diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/handler/request/impl/DefaultRequestCoordinator.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/handler/request/impl/DefaultRequestCoordinator.java index b1d0c440dd1d..a9a2ef6bea92 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/handler/request/impl/DefaultRequestCoordinator.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/handler/request/impl/DefaultRequestCoordinator.java @@ -1021,10 +1021,12 @@ private void buildOutboundQueryString(HttpServletRequest request, Authentication .append("&relyingParty=").append(URLEncoder.encode(context.getRelyingParty(), "UTF-8")) .append("&type=").append(context.getRequestType()).append("&") .append(FrameworkConstants.REQUEST_PARAM_SP).append("=") - .append(URLEncoder.encode(context.getServiceProviderName(), "UTF-8")).append("&") - .append(FrameworkConstants.REQUEST_PARAM_SP_UUID).append("=") - .append(URLEncoder.encode(context.getServiceProviderResourceId())).append("&") - .append("&isSaaSApp=") + .append(URLEncoder.encode(context.getServiceProviderName(), "UTF-8")).append("&"); + if (context.getServiceProviderResourceId() != null) { + outboundQueryStringBuilder.append(FrameworkConstants.REQUEST_PARAM_SP_UUID).append("=") + .append(URLEncoder.encode(context.getServiceProviderResourceId(), "UTF-8")).append("&"); + } + outboundQueryStringBuilder.append("&isSaaSApp=") .append(context.getSequenceConfig().getApplicationConfig().isSaaSApp()); } catch (UnsupportedEncodingException e) { throw new FrameworkException("Error while URL Encoding", e);