<?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 Creating AGSCredentials using Token and Referer in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/creating-agscredentials-using-token-and-referer/m-p/1006106#M6858</link>
    <description>&lt;P&gt;When view controller is loaded, it makes an API call to our server with the app identifier which is used by the API to generate a token using ArcGIS service. The response contains portal URL, token and mapId. The portal URL can be of following format:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://atlas.%7Bclient/" target="_blank" rel="nofollow noopener"&gt;https://atlas.{client&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Name}.com&lt;/LI&gt;&lt;LI&gt;https://{client Name}.maps.arcgis.com&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;and then use following code to load map and related basemaps&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;LI-CODE lang="swift"&gt;agsCredential = AGSCredential(token: portalToken, referer: referer)
let portal = AGSPortal(url: portalURL, loginRequired: true)
        portal.credential = agsCredential
        let portalItem = AGSPortalItem(portal: portal, itemID: mapId)
        let map = AGSMap(item: portalItem)
        esriMapView.map = map
        map.load { (error) in 
              // handle error or handle successfully loaded map
              // load base maps
}&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;Although I have provided the credentials, I still see credential challenge popup. If I create AGSCredentials using userName and password, it works fine.&lt;/P&gt;&lt;P&gt;Our requirement is to use token rather than userName and password, what is the best approach to use the token?&lt;/P&gt;&lt;P&gt;I also been communication on git, so I tried and what worked is in following link of ESRI iOS Repo.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-ios/issues/1012" target="_blank" rel="noopener"&gt;https://github.com/Esri/arcgis-runtime-samples-ios/issues/1012&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Dec 2020 06:21:03 GMT</pubDate>
    <dc:creator>smaawais</dc:creator>
    <dc:date>2020-12-02T06:21:03Z</dc:date>
    <item>
      <title>Creating AGSCredentials using Token and Referer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/creating-agscredentials-using-token-and-referer/m-p/1006106#M6858</link>
      <description>&lt;P&gt;When view controller is loaded, it makes an API call to our server with the app identifier which is used by the API to generate a token using ArcGIS service. The response contains portal URL, token and mapId. The portal URL can be of following format:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://atlas.%7Bclient/" target="_blank" rel="nofollow noopener"&gt;https://atlas.{client&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Name}.com&lt;/LI&gt;&lt;LI&gt;https://{client Name}.maps.arcgis.com&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;and then use following code to load map and related basemaps&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;LI-CODE lang="swift"&gt;agsCredential = AGSCredential(token: portalToken, referer: referer)
let portal = AGSPortal(url: portalURL, loginRequired: true)
        portal.credential = agsCredential
        let portalItem = AGSPortalItem(portal: portal, itemID: mapId)
        let map = AGSMap(item: portalItem)
        esriMapView.map = map
        map.load { (error) in 
              // handle error or handle successfully loaded map
              // load base maps
}&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;Although I have provided the credentials, I still see credential challenge popup. If I create AGSCredentials using userName and password, it works fine.&lt;/P&gt;&lt;P&gt;Our requirement is to use token rather than userName and password, what is the best approach to use the token?&lt;/P&gt;&lt;P&gt;I also been communication on git, so I tried and what worked is in following link of ESRI iOS Repo.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-ios/issues/1012" target="_blank" rel="noopener"&gt;https://github.com/Esri/arcgis-runtime-samples-ios/issues/1012&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 06:21:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/creating-agscredentials-using-token-and-referer/m-p/1006106#M6858</guid>
      <dc:creator>smaawais</dc:creator>
      <dc:date>2020-12-02T06:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating AGSCredentials using Token and Referer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/creating-agscredentials-using-token-and-referer/m-p/1007128#M6862</link>
      <description>&lt;P&gt;What type of layers present in the portalItem? Are they hosted feature layers? If yes, it requires another credential/token generated using portalToken. Can you please post the credential challenge information?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nimesh&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 00:22:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/creating-agscredentials-using-token-and-referer/m-p/1007128#M6862</guid>
      <dc:creator>NimeshJarecha</dc:creator>
      <dc:date>2020-12-05T00:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating AGSCredentials using Token and Referer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/creating-agscredentials-using-token-and-referer/m-p/1007191#M6863</link>
      <description>&lt;P&gt;Hi Nimesh,&lt;/P&gt;&lt;P&gt;The layers I wan to access are within the basemap, how set credentials again? Following is how I am doing right now. Also what credential challenge information are you after?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;/SPAN&gt; agsCredentials = &lt;SPAN class="s2"&gt;AGSCredential&lt;/SPAN&gt;(token: credentialToken, referer: referer)&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;/SPAN&gt; portal = &lt;SPAN class="s2"&gt;AGSPortal&lt;/SPAN&gt;(url: portalURL, loginRequired: &lt;SPAN class="s1"&gt;&lt;STRONG&gt;true&lt;/STRONG&gt;&lt;/SPAN&gt;)&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;portal.&lt;/SPAN&gt;credential =&amp;nbsp;&amp;nbsp;agsCredentials&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;/SPAN&gt; portalItem = &lt;SPAN class="s2"&gt;AGSPortalItem&lt;/SPAN&gt;(portal: portal, itemID: mapId)&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;/SPAN&gt; map = &lt;SPAN class="s2"&gt;AGSMap&lt;/SPAN&gt;(item: portalItem)&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s3"&gt;esriMapView&lt;/SPAN&gt;.&lt;SPAN class="s3"&gt;map&lt;/SPAN&gt; = map&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;map.&lt;SPAN class="s3"&gt;load&lt;/SPAN&gt; { (error) &lt;SPAN class="s1"&gt;&lt;STRONG&gt;in&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;_&lt;/STRONG&gt;&lt;/SPAN&gt; = error {&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s4"&gt;print&lt;/SPAN&gt;(error!.&lt;SPAN class="s4"&gt;localizedDescription&lt;/SPAN&gt;)&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;self&lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;SPAN class="s3"&gt;delegate&lt;/SPAN&gt;?.&lt;SPAN class="s3"&gt;mapLoadingFailed&lt;/SPAN&gt;()&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;} &lt;SPAN class="s1"&gt;&lt;STRONG&gt;else&lt;/STRONG&gt;&lt;/SPAN&gt; {&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;var&lt;/STRONG&gt;&lt;/SPAN&gt; layers = &lt;SPAN class="s2"&gt;MapSpecificLayers&lt;/SPAN&gt;()&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;for&lt;/STRONG&gt;&lt;/SPAN&gt; layer &lt;SPAN class="s1"&gt;&lt;STRONG&gt;in&lt;/STRONG&gt;&lt;/SPAN&gt; map.&lt;SPAN class="s3"&gt;operationalLayers&lt;/SPAN&gt; {&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;/SPAN&gt; agsLayer = layer &lt;SPAN class="s1"&gt;&lt;STRONG&gt;as&lt;/STRONG&gt;&lt;/SPAN&gt;? &lt;SPAN class="s2"&gt;AGSLayer&lt;/SPAN&gt; {&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;let&lt;/STRONG&gt;&lt;/SPAN&gt; mSpecifiLayer = &lt;SPAN class="s2"&gt;MapSpecificLayer&lt;/SPAN&gt;(id: agsLayer.&lt;SPAN class="s3"&gt;layerID&lt;/SPAN&gt;,&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;layerName: agsLayer.&lt;SPAN class="s3"&gt;name&lt;/SPAN&gt;,&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;isVisible: agsLayer.&lt;SPAN class="s3"&gt;opacity&lt;/SPAN&gt; &lt;SPAN class="s4"&gt;==&lt;/SPAN&gt; &lt;SPAN class="s5"&gt;0&lt;/SPAN&gt; ? &lt;SPAN class="s1"&gt;&lt;STRONG&gt;false&lt;/STRONG&gt;&lt;/SPAN&gt; : &lt;SPAN class="s1"&gt;&lt;STRONG&gt;true&lt;/STRONG&gt;&lt;/SPAN&gt;)&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;layers.&lt;SPAN class="s4"&gt;append&lt;/SPAN&gt;(mSpecifiLayer)&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;self&lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;SPAN class="s3"&gt;layersViewModel&lt;/SPAN&gt;.&lt;SPAN class="s3"&gt;mapSpecificLayersFetched&lt;/SPAN&gt;(mapSpecificLayers: layers)&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;self&lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;SPAN class="s3"&gt;delegate&lt;/SPAN&gt;?.&lt;SPAN class="s3"&gt;mapLoaded&lt;/SPAN&gt;()&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;portal.&lt;SPAN class="s3"&gt;fetchBasemaps&lt;/SPAN&gt; { (bmaps, err) &lt;SPAN class="s1"&gt;&lt;STRONG&gt;in&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p3"&gt;&lt;SPAN class="s6"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="s4"&gt;print&lt;/SPAN&gt;&lt;SPAN class="s6"&gt;(&lt;/SPAN&gt;"&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;. BASE MAP FETCHED &lt;SPAN class="s6"&gt;\(bmaps?.&lt;/SPAN&gt;&lt;SPAN class="s4"&gt;count&lt;/SPAN&gt;&lt;SPAN class="s6"&gt;)&lt;/SPAN&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;"&lt;SPAN class="s6"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Dec 2020 02:14:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/creating-agscredentials-using-token-and-referer/m-p/1007191#M6863</guid>
      <dc:creator>smaawais</dc:creator>
      <dc:date>2020-12-06T02:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating AGSCredentials using Token and Referer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/creating-agscredentials-using-token-and-referer/m-p/1009923#M6871</link>
      <description>&lt;P&gt;Can you capture all request/responses and send to me in direct message? If possible, send a reproducible sample project too so I can help you where to set another credential.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nimesh&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 21:09:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/creating-agscredentials-using-token-and-referer/m-p/1009923#M6871</guid>
      <dc:creator>NimeshJarecha</dc:creator>
      <dc:date>2020-12-15T21:09:34Z</dc:date>
    </item>
  </channel>
</rss>

