<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcGIS Server Token with VectorTileLayer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1107391#M74959</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;Thanks for your reply. I've tried to implement a test page that works but it still doesnt draw the map. Here is the code and a link to &lt;A href="https://jsfiddle.net/mirhashmi/7mwrh2zf/1/" target="_blank" rel="noopener"&gt;jsfiddle&lt;/A&gt;.&amp;nbsp; Looking at the dev tools network tab, I can see that it loads required urls with the token but still map doesn't draw.&amp;nbsp; Am I missing something here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=Edge" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;title&amp;gt;VectorTileLayer | Sample | ArcGIS API for JavaScript 4.21&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.21/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.21/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/VectorTileLayer",
        "esri/config"
      ], (Map, MapView, VectorTileLayer, esriConfig) =&amp;gt; {
        // Create a Map
        const map = new Map();

        // Make map view and bind it to the map
        const view = new MapView({
          container: "viewDiv",
          map: map,
          center: [46.897998, 24.598897],
          zoom: 5
        });

        /********************************************************************
         * Add a vector tile layer to the map
         *
         * The url must point to the style or the vector tile service
         *********************************************************************/
        const tileLayer = new VectorTileLayer({
          url: "https://abc.ab.ca/server/rest/services/Hosted/MyMapService/VectorTileServer"
        });

        const interceptor = {
          urls: tileLayer.url,
          before: function (params) {
            params.requestOptions.query.token =
              "Xj9OUDvMFYz3BHd3fcPnHiJdmmae9gWrfT4WL-VFmJjwoeu82JSC4SCzPc18a7Z_c0VaS-xdFD3neOCtAhn0rKIXaSE7ilsN7Z4F0xTclcGYsDNI-E1UyKtL5YmSkgphSRlwfsrAOU9rEqzu4Z_LDo9b6XFUCi00S5glYTv28pE.";
          }
        };

        esriConfig.request.interceptors.push(interceptor);

        map.add(tileLayer);
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Oct 2021 15:52:06 GMT</pubDate>
    <dc:creator>MirHashmi</dc:creator>
    <dc:date>2021-10-14T15:52:06Z</dc:date>
    <item>
      <title>ArcGIS Server Token with VectorTileLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1106662#M74929</link>
      <description>&lt;P&gt;Is there a way to access secured service through VectorTileLayer in ArcGIS JS API.&amp;nbsp; I have tried with using methods - &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/how-do-i-add-a-secured-feature-service-using-a/m-p/1040881#M72219" target="_blank" rel="noopener"&gt;interceptor&lt;/A&gt; and&amp;nbsp; &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#customParameters" target="_self"&gt;CustomParameters&lt;/A&gt; - but nothing seems to work. Am I missing something?&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Generated token&lt;BR /&gt;2. Tried to append token in interceptor and customparameters&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;myBaseMapUrl&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;A href="https://abc.ab.ca/server/rest/services/Hosted/ILoveMapV1_0/VectorTileServer/resources/styles/root.json" target="_blank" rel="noopener"&gt;https://abc.ab.ca/server/rest/services/Hosted/ILoveMapV1_0/VectorTileServer/resources/styles/root.json&lt;/A&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;oLBaseMapUrl&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;A href="https://www.arcgis.com/sharing/rest/content/items/3e1a00aeae81496587988075fe529f71/resources/styles/root.json" target="_blank" rel="noopener"&gt;https://www.arcgis.com/sharing/rest/content/items/3e1a00aeae81496587988075fe529f71/resources/styles/root.json&lt;/A&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;; &lt;/SPAN&gt;&lt;SPAN&gt;//openlayers&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// esriConfig.request.interceptors.push({&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// &amp;nbsp; urls: myBaseMapUrl,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// &amp;nbsp; before: function(params) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// &amp;nbsp; &amp;nbsp; params.requestOptions.query = params.requestOptions.query || {};&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// &amp;nbsp; &amp;nbsp; params.requestOptions.query.token = this.accesstoken;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// });&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// My Basemap vector tile layer&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;myBaseMapLayers&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;VectorTileLayer&lt;/SPAN&gt;&lt;SPAN&gt;({ &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;url&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;prd&lt;/SPAN&gt;&lt;SPAN&gt;) ? &lt;/SPAN&gt;&lt;SPAN&gt;myBaseMapUrl&lt;/SPAN&gt;&lt;SPAN&gt; : &lt;/SPAN&gt;&lt;SPAN&gt;oLBaseMapUrl&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;customParameters&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; { &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"token"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;accesstoken&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My application always presents me with the credentials dialog box and I do not need it.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 11:51:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1106662#M74929</guid>
      <dc:creator>MirHashmi</dc:creator>
      <dc:date>2021-10-12T11:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server Token with VectorTileLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1106751#M74936</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;The customParameters is not supported on VectorTileLayer so setting it on the layer won't help. However, the before interceptors will work. If you are being asked to login that means you still have urls that need to have the token attached. Y&lt;SPAN&gt;ou can look in the network tab to see where it's being sent and which response says it needs a token. Copy those urls and add them to the interceptor urls. Your vector tiles will display without a login&amp;nbsp;promo, once all urls requiring&amp;nbsp;tokens are added to the interceptor urls. I have tested and verified that it works as expected.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is my simple test (token is already expired in this case) and I am adding vector tiles from a protected&amp;nbsp;portal item however the service itself is publicly accessible (so I&amp;nbsp;don't have to add urls for the service).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  const interceptor = {
          urls: [
            "https://www.arcgis.com/sharing/rest/content/items/92499d146008498091eed0ffaa4b09d5"
          ],
          before({ url, requestOptions }) {
            requestOptions.query.token = "10ilTU8DrsMBMrmj2kApv1pkhFn0MS1OhjNoAzFWU7DUeQufPC9xNj-4lDd0Di1MTSHzwzPKwDdDiE1gDRcXTAxWsFVyCbVoFsChB_9Ez1C6NSqkRE3mftygP_2zW3KEDrmRw87zcwFxezZ9Q9SW0AxlxOeVAZf1o0G5wSwvF11J8jRovtfqunLunkjXQiFFViTKgnDM5NbOc7TAU5uyUes3piH5FCWxts36StJUMAw.";
          }
        };

        esriConfig.request.interceptors.push(interceptor);
        const map = new Map();

        // Make map view and bind it to the map
        const view = new MapView({
          container: "viewDiv",
          map: map,
          center: [-98.5795, 39.8282],
          zoom: 3
        });

        const tileLayer = new VectorTileLayer({
          portalItem: {
            id: "92499d146008498091eed0ffaa4b09d5"
          }
        });
        map.add(tileLayer);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope this helps,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-Undral&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 16:33:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1106751#M74936</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-10-12T16:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server Token with VectorTileLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1106787#M74939</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Did you try this? Adding the service to ArcGIS online and turning on "&lt;STRONG&gt;Store Credentials with service item. Do not prompt for authentication.&lt;/STRONG&gt;" And then, share the item you added to public.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SailiTang1_0-1634061244985.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25039i45ABB526511CBF50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SailiTang1_0-1634061244985.png" alt="SailiTang1_0-1634061244985.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 17:57:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1106787#M74939</guid>
      <dc:creator>SailiTang1</dc:creator>
      <dc:date>2021-10-12T17:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server Token with VectorTileLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1107388#M74958</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/163433"&gt;@SailiTang1&lt;/a&gt;&amp;nbsp; Thanks for your reply. However, I do not have an ArcGIS online option available. The service is available on premises arcgis portal. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 03:07:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1107388#M74958</guid>
      <dc:creator>MirHashmi</dc:creator>
      <dc:date>2021-10-14T03:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server Token with VectorTileLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1107391#M74959</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;Thanks for your reply. I've tried to implement a test page that works but it still doesnt draw the map. Here is the code and a link to &lt;A href="https://jsfiddle.net/mirhashmi/7mwrh2zf/1/" target="_blank" rel="noopener"&gt;jsfiddle&lt;/A&gt;.&amp;nbsp; Looking at the dev tools network tab, I can see that it loads required urls with the token but still map doesn't draw.&amp;nbsp; Am I missing something here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=Edge" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;title&amp;gt;VectorTileLayer | Sample | ArcGIS API for JavaScript 4.21&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.21/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.21/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/VectorTileLayer",
        "esri/config"
      ], (Map, MapView, VectorTileLayer, esriConfig) =&amp;gt; {
        // Create a Map
        const map = new Map();

        // Make map view and bind it to the map
        const view = new MapView({
          container: "viewDiv",
          map: map,
          center: [46.897998, 24.598897],
          zoom: 5
        });

        /********************************************************************
         * Add a vector tile layer to the map
         *
         * The url must point to the style or the vector tile service
         *********************************************************************/
        const tileLayer = new VectorTileLayer({
          url: "https://abc.ab.ca/server/rest/services/Hosted/MyMapService/VectorTileServer"
        });

        const interceptor = {
          urls: tileLayer.url,
          before: function (params) {
            params.requestOptions.query.token =
              "Xj9OUDvMFYz3BHd3fcPnHiJdmmae9gWrfT4WL-VFmJjwoeu82JSC4SCzPc18a7Z_c0VaS-xdFD3neOCtAhn0rKIXaSE7ilsN7Z4F0xTclcGYsDNI-E1UyKtL5YmSkgphSRlwfsrAOU9rEqzu4Z_LDo9b6XFUCi00S5glYTv28pE.";
          }
        };

        esriConfig.request.interceptors.push(interceptor);

        map.add(tileLayer);
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 15:52:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-server-token-with-vectortilelayer/m-p/1107391#M74959</guid>
      <dc:creator>MirHashmi</dc:creator>
      <dc:date>2021-10-14T15:52:06Z</dc:date>
    </item>
  </channel>
</rss>

