Select to view content in your preferred language

100.1 Rest Basemap with Token

700
1
11-30-2017 10:14 AM
DenisO_Connor
Emerging Contributor

Currently moving from Runtime 10.1.1 to 100.1 ...

10.1.1 Code to load Rest Basemap was...

Dim NewTiledLayer As New ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer()
With NewTiledLayer
      .Url = "https://mapgenie.osi.ie/arcgis/rest/services/WM/basemap_premium/MapServer "
      .Token = "abcdefghigh123456789"
End With
MyMap.Layers.Add(NewTiledLayer)

What is the equivalent code in 100.1 ?

0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor

In v100.x, you no longer set a Token property. You may set Credential or implement ChallengeHandler.

AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async (info) =>
{
    // Option A: Use ChallengeHandler to prompt for login
    return await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, "username", "password");
});
var layer = new ArcGISMapImageLayer(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire_secure/MapServer"));
// Option B: Set Credential property
layer.Credential = await AuthenticationManager.Current.GenerateCredentialAsync(layer.Source, "user1", "user1");
MyMapView.Map = new Map(new Basemap(layer));
0 Kudos