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


<UserControl x:Class="ArcGISRuntime.WPF.Samples.TokenSecuredKnownUser.TokenSecuredKnownUser"
    <Grid x:Name="layoutGrid">
        <esri:MapView x:Name="MyMapView">
                <!-- This layer is public and does not require credentials -->
                <esri:ArcGISTiledLayer Name="World Street Map - Public"
					Source="" />
                <!-- This layer is secured with ArcGIS tokens and requires a login -->
                <!--username: user1 | password: user1-->
                <esri:ArcGISMapImageLayer Name="USA - Secure"
					Source="" />

        <!-- Layer listing with status -->
        <Border Background="White" BorderBrush="Black" BorderThickness="2" 
				HorizontalAlignment="Right" VerticalAlignment="Top">
                <TextBlock FontSize="14" FontWeight="Bold"
                           Text="Map Layers (with status)" />
                <ListView x:Name="listLayerStatus" 
                          ItemsSource="{Binding ElementName=MyMapView, Path=Map.AllLayers}">
                                <TextBlock Text="{Binding Name}" 
                                           HorizontalAlignment="Left" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Margin="20,0,0,5" 
                                            <Style TargetType="{x:Type TextBlock}">
                                                    <DataTrigger Binding="{Binding LoadStatus}" 
                                                        <Setter Property="Foreground" Value="Red" />
                                                        <Setter Property="Text" Value="Access Denied" />
                                                    <DataTrigger Binding="{Binding LoadStatus}" Value="0">
                                                        <Setter Property="Foreground" Value="Green" />
                                                        <Setter Property="Text" Value="Access Granted" />

                                                    <Setter Property="Foreground" Value="Black" />
                                                    <Setter Property="Text" Value="Initializing" />

In this topic
  1. Code