diff --git a/modules/distribution/resources/api_templates/velocity_template.xml b/modules/distribution/resources/api_templates/velocity_template.xml
index 4732d712ef..f681cb2ebd 100644
--- a/modules/distribution/resources/api_templates/velocity_template.xml
+++ b/modules/distribution/resources/api_templates/velocity_template.xml
@@ -31,6 +31,8 @@
#set( $endpointClass = $endpoint_config.get("endpoint_type") )
#set( $endpoints = $endpoint_config.get("${type}_endpoints"))
#set( $ep_key = "${endpointKey}_API${type}Endpoint")
+ #set( $endpointSecurityProd = $endpoint_security.get("production"))
+ #set( $endpointSecuritySand = $endpoint_security.get("sandbox"))
#set( $endpointsecurity = $endpoint_security.get("${type}"))
## IF endpoint secured
#if($endpointsecurity.enabled)
@@ -346,8 +348,19 @@ $out_sequences.get("$resource.getUriTemplate()").get($uri)
#if( $responseCacheEnabled )
#end
- #if( $endpointsecurity.type == "oauth" || $endpointsecurity.type == "OAUTH" )
-
+ #if( $apiIsOauthProtected || $apiIsApiKeyProtected || $apiIsBasicAuthProtected )
+
+
+ #if($endpointSecurityProd.clientId && ($endpointSecurityProd.type == "oauth" || $endpointSecurityProd.type == "OAUTH"))
+
+ #end
+
+
+ #if($endpointSecuritySand.clientId && ($endpointSecuritySand.type == "oauth" || $endpointSecuritySand.type == "OAUTH"))
+
+ #end
+
+
#end