Click or drag to resize

Credential Class

Base class that represents a credential object used to access a secured ArcGIS resource.
Inheritance Hierarchy

Namespace:  Esri.ArcGISRuntime.Security
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
public abstract class Credential : INotifyPropertyChanged, 

The Credential type exposes the following members.

Public propertyCode exampleServiceUri
Gets or sets the URI of the service that can be accessed with this credential.
Public eventPropertyChanged
Occurs when a property value changes.
You will generally get an instance of this class by calling GetCredentialAsync.


Example Name: ReverseGeocode

Use an online service to find the address for a tapped point.

Code example screen shot.

// Copyright 2019 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.Tasks.Geocoding;
using Esri.ArcGISRuntime.UI;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;

namespace ArcGISRuntime.WPF.Samples.ReverseGeocode
        name: "Reverse geocode",
        category: "Search",
        description: "Use an online service to find the address for a tapped point.",
        instructions: "Tap the map to see the nearest address displayed in a callout.",
        tags: new[] { "address", "geocode", "locate", "reverse geocode", "search" })]
    public partial class ReverseGeocode
        // Service Uri to be provided to the LocatorTask (geocoder).
        private readonly Uri _serviceUri = new Uri("");

        // The LocatorTask provides geocoding services.
        private LocatorTask _geocoder;

        public ReverseGeocode()

        private async void Initialize()
            // Create new Map with basemap.
            Map myMap = new Map(BasemapStyle.ArcGISImagery);

            // Provide used Map to the MapView.
            MyMapView.Map = myMap;

            // Add a graphics overlay to the map for showing where the user tapped.
            MyMapView.GraphicsOverlays.Add(new GraphicsOverlay());

            // Enable tap-for-info pattern on results.
            MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;

            // Initialize the LocatorTask with the provided service Uri.
                _geocoder = await LocatorTask.CreateAsync(_serviceUri);
            catch (Exception e)
                MessageBox.Show(e.ToString(), "Error");

            // Set the initial viewpoint.
            await MyMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4);

        private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
                // Clear the existing graphics & callouts.

                // Add a graphic for the tapped point.
                Graphic pinGraphic = await GraphicForPoint(e.Location);

                // Normalize the geometry - needed if the user crosses the international date line.
                MapPoint normalizedPoint = (MapPoint)GeometryEngine.NormalizeCentralMeridian(e.Location);

                // Reverse geocode to get addresses.
                IReadOnlyList<GeocodeResult> addresses = await _geocoder.ReverseGeocodeAsync(normalizedPoint);

                // Get the first result.
                GeocodeResult address = addresses.First();

                // Use the city and region for the Callout Title.
                string calloutTitle = address.Attributes["Address"].ToString();

                // Use the metro area for the Callout Detail.
                string calloutDetail = address.Attributes["City"] +
                                       " " + address.Attributes["Region"] +
                                       " " + address.Attributes["CountryCode"];

                // Define the callout.
                CalloutDefinition calloutBody = new CalloutDefinition(calloutTitle, calloutDetail);

                // Show the callout on the map at the tapped location.
                MyMapView.ShowCalloutForGeoElement(pinGraphic, e.Position, calloutBody);
            catch (Exception ex)
                MessageBox.Show("No results found.", "No results");

        private async Task<Graphic> GraphicForPoint(MapPoint point)
            // Get current assembly that contains the image.
            Assembly currentAssembly = Assembly.GetExecutingAssembly();

            // Get image as a stream from the resources.
            // Picture is defined as EmbeddedResource and DoNotCopy.
            Stream resourceStream = currentAssembly.GetManifestResourceStream(

            // Create new symbol using asynchronous factory method from stream.
            PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream);
            pinSymbol.Width = 60;
            pinSymbol.Height = 60;
            // The image is a pin; offset the image so that the pinpoint
            //     is on the point rather than the image's true center.
            pinSymbol.LeaderOffsetX = 30;
            pinSymbol.OffsetY = 14;
            return new Graphic(point, pinSymbol);
<UserControl x:Class="ArcGISRuntime.WPF.Samples.ReverseGeocode.ReverseGeocode"
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Label Content="Tap to find the nearest address."
                   HorizontalAlignment="Center" FontWeight="SemiBold" />
See Also
Additional Examples
Hyperlink to ExampleDescription
AuthorMapCreate and save a map as an ArcGIS `PortalItem` (i.e. web map).
CertificateAuthenticationWithPkiAccess secured portals using a certificate.
ClosestFacilityFind a route to the closest facility from a location.
ClosestFacilityStaticFind routes from several locations to the respective closest facility.
ConfigureSubnetworkTraceGet a server-defined trace configuration for a given tier and modify its traversability scope, add new condition barriers and control what is included in the subnetwork trace result.
DisplaySubtypeFeatureLayerDisplays a composite layer of all the subtype values in a feature class.
DisplayUtilityAssociationsCreate graphics for utility associations in a utility network.
EditAndSyncFeaturesSynchronize offline edits with a feature service.
EditBranchVersioningCreate, query and edit a specific server version using service geodatabase.
ExportTilesDownload tiles to a local tile cache file stored on the device.
FindAddressFind the location for an address.
FindPlaceFind places of interest near a location or within a specific area.
FindRouteDisplay directions for a route between two points.
FindServiceAreaFind the service area within a network from a given point.
FindServiceAreasForMultipleFacilitiesFind the service areas of several facilities from a feature service.
GenerateGeodatabaseGenerate a local geodatabase from an online feature service.
GenerateOfflineMapTake a web map offline.
GenerateOfflineMapWithOverridesTake a web map offline with additional options for each layer.
GeodatabaseTransactionsUse transactions to manage how changes are committed to a geodatabase.
IntegratedWindowsAuthConnect to an IWA secured Portal and search for maps.
ListRelatedFeaturesList features related to the selected feature.
NavigateRouteUse a routing service to navigate between points.
OAuthAuthenticate with ArcGIS Online (or your own portal) using OAuth2 to access secured resources (such as private web maps or layers).
OfflineBasemapByReferenceUse the `OfflineMapTask` to take a web map offline, but instead of downloading an online basemap, use one which is already on the device.
OfflineGeocodeGeocode addresses to locations and reverse geocode locations to addresses offline.
PerformValveIsolationTraceRun a filtered trace to locate operable features that will isolate an area from the flow of network resources.
ReverseGeocodeUse an online service to find the address for a tapped point.
RouteAroundBarriersFind a route that reaches all stops without crossing any barriers.
SearchPortalMapsFind webmap portal items by using a search term.
TokenSecuredChallengeThis sample demonstrates how to prompt the user for a username and password to authenticate with ArcGIS Server to access an ArcGIS token-secured service. Accessing secured services requires a login that's been defined on the server.
TraceUtilityNetworkDiscover connected features in a utility network using connected, subnetwork, upstream, and downstream traces.