Show / Hide Table of Contents

Property ApiKey

ApiKey

Gets or sets the API key that allows your app to access ArcGIS location services and private portal items.

Declaration
public string ApiKey { get; set; }
Property Value
Type Description
System.String

The API key that allows your app to access ArcGIS location services and private portal items.

Implements
IApiKeyResource.ApiKey
Remarks

An API key is a unique long-lived access token that is used to authenticate and monitor requests to ArcGIS location services and private portal items. You can create and manage an API key using your portal when you sign in with an ArcGIS Location Platform account or an ArcGIS Online account with administrator access or a custom role that has the Generate API keys privilege. To learn how to create and manage API keys, go to the Create an API Key tutorial. You must ensure that your API key has the correct privileges to access secure resources.

Setting the API key on a specific resource overrides the default key set on ApiKey.

In addition to setting an ApiKey at a global level for your application, you can set it on any class that implements IApiKeyResource. This overrides the ApiKey and enables more granular usage telemetry and management of ArcGIS location resources used by your app.

Classes that expose an API key property by implementing IApiKeyResource include:

  • ArcGISSceneLayer
  • ArcGISTiledLayer
  • ArcGISVectorTiledLayer
  • Basemap
  • Esri.ArcGISRuntime.Mapping.BasemapStylesService
  • ClosestFacilityTask
  • ExportTileCacheTask
  • ExportVectorTilesTask
  • GeodatabaseSyncTask
  • LocatorTask
  • RouteTask
  • ServiceAreaTask
  • ServiceFeatureTable

Note: An API key created with a referrer is not supported. If you need service requests to include the referrer, call UseDefaultReferer(IArcGISHttpConfiguration, Uri) when initializing the ArcGISRuntimeEnvironment.

var myReferer = new Uri("http://foo.bar");
ArcGISRuntimeEnvironment.Initialize(
    config => config.UseApiKey("AAPK...")
        .ConfigureHttp(
            httpConfig => httpConfig.UseDefaultReferer(myReferer)));

For more information, see API key authentication and Types of authentication.

Applies to

Platforms and versions
TargetVersions
.NET Standard 2.0100.11 - 200.7
.NET100.13 - 200.7
.NET Windows100.13 - 200.7
.NET Android200.0 - 200.7
.NET iOS200.0 - 200.7
.NET Framework100.11 - 200.7
Xamarin.Android100.11 - 100.15
Xamarin.iOS100.11 - 100.15
UWP100.11 - 200.7
In This Article
Back to top Copyright © 2022 Esri.