Token Authentication - Known User

This sample demonstrates accessing secured services using ArcGIS token-based authentication. Token-based authentication is supported for ArcGIS Server, ArcGIS Online, and ArcGIS Enterprise version 10.2 or earlier. In this sample, a hard-coded username and password is used to get an ArcGIS token for accessing a secured resource. This process is seamless to the user, since no dialog appears to prompt for the username and password. This sample provides a basic example, in a real-world sceneario, better protection of the username and password would be required (calling a secured web service to get the token, for example). To see an example of using the ArcGIS Runtime SDK for .NET AuthenticationManager to prompt for credentials, see the Token Secured Services (Challenge method) sample.

Secure service loaded using hard-coded token credentials

Code

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.TokenSecuredKnownUser.TokenSecuredKnownUser"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:ArcGISRuntimeXamarin.Samples.TokenSecuredChallenge"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
    <ContentPage.Resources>
        <ResourceDictionary>
            <local:LoadStatusToColorConverter x:Key="StatusToColor"/>
        </ResourceDictionary>
    </ContentPage.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <StackLayout x:Name="PublicLayerStatusPanel"
                 Grid.Row="0"
                 Orientation="Horizontal"
                 Margin="10,3">
            <Label Text="{Binding Name}"
             Margin="5,0"/>
            <Label Text="{Binding LoadStatus}"
             TextColor="{Binding LoadStatus, Converter={StaticResource StatusToColor}}"/>
        </StackLayout>
        <StackLayout x:Name="SecureLayerStatusPanel"
                 Grid.Row="1"
                 Orientation="Horizontal"
                 Margin="10,3">
            <Label Text="{Binding Name}"
             Margin="5,0"/>
            <Label Text="{Binding LoadStatus}"
             TextColor="{Binding LoadStatus, Converter={StaticResource StatusToColor}}"/>
        </StackLayout>
        <esriUI:MapView x:Name="MyMapView"
                    Grid.Row="2"/>
    </Grid>
</ContentPage>


In this topic
  1. Code