diff --git a/src/main/java/it/inaf/oats/vospace/UriService.java b/src/main/java/it/inaf/oats/vospace/UriService.java
index 87557c9c14d9db25205af9c441497ce5d549ee2e..171c49be04fc4aafb81c143399cdbd381f28bdb2 100644
--- a/src/main/java/it/inaf/oats/vospace/UriService.java
+++ b/src/main/java/it/inaf/oats/vospace/UriService.java
@@ -130,9 +130,9 @@ public class UriService {
                                 Protocol protocol = new Protocol();
                                 protocol.setUri(p.getUri());
                                 protocol.setEndpoint(endpoint);
-                                return protocol;                                
+                                return protocol;
                             } else {
-                                return null;                                
+                                return null;
                             }
                         }).filter(Objects::nonNull)
                         .collect(Collectors.toList());
@@ -224,6 +224,10 @@ public class UriService {
 
         if (isLinkNode) {
             endpoint = ((LinkNode) node).getTarget();
+            String linkTarget = ((LinkNode) node).getTarget();
+            if (linkedServiceDAO.isLinkedServiceUrl(linkTarget)) {
+                endpoint += "&token=" + getEndpointToken(linkTarget);
+            }
         } else {
 
             Location location = locationDAO.getNodeLocation(relativePath).orElse(null);
@@ -238,17 +242,12 @@ public class UriService {
             } else {
                 endpoint = fileServiceUrl + urlEncodePath(relativePath);
             }
-        }
 
-        endpoint += "?jobId=" + job.getJobId();
+            endpoint += "?jobId=" + job.getJobId();
 
-        if (isLinkNode) {
-            String linkTarget = ((LinkNode) node).getTarget();
-            if (linkedServiceDAO.isLinkedServiceUrl(linkTarget)) {
-                endpoint += "&token=" + getEndpointToken(linkTarget);
+            if (!"true".equals(NodeProperties.getNodePropertyByURI(node, NodeProperties.PUBLIC_READ_URI))) {
+                endpoint += "&token=" + getEndpointToken(fileServiceUrl + relativePath);
             }
-        } else if (!"true".equals(NodeProperties.getNodePropertyByURI(node, NodeProperties.PUBLIC_READ_URI))) {
-            endpoint += "&token=" + getEndpointToken(fileServiceUrl + relativePath);
         }
 
         return endpoint;
@@ -364,7 +363,7 @@ public class UriService {
             return this.uri;
         }
 
-        public boolean isEndpointCompliant(String endpoint) {            
+        public boolean isEndpointCompliant(String endpoint) {
             return endpoint.toLowerCase()
                     .startsWith(this.protocolString + "://");
         }