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
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
Target | Versions |
---|---|
.NET Standard 2.0 | 100.11 - 200.6 |
.NET | 100.13 - 200.6 |
.NET Windows | 100.13 - 200.6 |
.NET Android | 200.0 - 200.6 |
.NET iOS | 200.0 - 200.6 |
.NET Framework | 100.11 - 200.6 |
Xamarin.Android | 100.11 - 100.15 |
Xamarin.iOS | 100.11 - 100.15 |
UWP | 100.11 - 200.6 |