ArcGIS Location Platform supports secure access to location services and private data. It ensures that only valid, authorized users and services access protected information. To access secure resources, you need to implement an authentication method so your applications can make authenticated requests to services.
An authentication method is the process used obtain an access token. Your app must present an access token whenever it makes an authenticated request to location services. Access tokens define the privileges available to your application. The authentication method you use to get an access token will vary.
There are three types of authentication that can be used to obtain an access token:
- API key authentication: grants a long-lived access token to authenticate requests to ArcGIS location services and, with an ArcGIS Location Platform account, private content. Go to the Create an API key tutorial to obtain a new API Key access token. It is the recommended type of authentication for developers new to ArcGIS or to development in general.
- User authentication: grants a short-lived token, generated via OAuth, giving your application permission to access the content and services authorized to an existing ArcGIS user's account.
- App authentication: grants a short-lived token, generated via OAuth, authorizing your application to access location services.
To make authenticated requests to services, you need to set the token
parameter to an access token.
API key authentication
An API Key can grant your public-facing application access to specific ArcGIS location services, and, with an ArcGIS Location Platform account, private content, items, and limited client referrers.
Use API key authentication when you want to:
- Quickly write applications that consume location services.
- Provide access to services without requiring users to sign in with an ArcGIS account.
Use an API key in your ArcGIS Runtime app
The API key access token can authorize access to specific ArcGIS Online services and resources from your app, as well as to monitor access to those services. Go to the Create an API key tutorial to obtain a new access token.
If you set the access token on the
ArcGISRuntimeEnvironment
using this access token, all requests made by your app will be authorized using this token. You can also set an access token on any ArcGIS Runtime class that implements
APIKeyResourceInterface
. When you set an access token for a specific class, it will override any access token you may have set on
ArcGISRuntimeEnvironment
, enabling more granular usage telemetry and management for ArcGIS Online resources by using the ArcGIS Location Platform.
Classes that implement
APIKeyResourceInterface
include:
-
Basemap
-
ArcGISSceneLayer
-
ArcGISTiledLayer
-
ArcGISVectorTiledLayer
-
ServiceFeatureTable
-
ExportVectorTilesTask
-
LocatorTask
-
GeodatabaseSyncTask
-
ClosestFacilityTask
-
RouteTask
-
ServiceAreaTask
-
ExportTileCacheTask
User authentication
User authentication is a set of authentication workflows that allow users with an ArcGIS account to sign into an application and access ArcGIS content, services, and resources. The typical authentication protocol used is OAuth2.0. When a user signs into an application with their ArcGIS account, an access token is generated that authorizes the application to access services and content on their behalf. The resources and functionality available depend on the user type, roles, and privileges of the user's ArcGIS account.
Service your app accesses through user authentication will be billed to the authenticated user's ArcGIS account and its associated ArcGIS subscription. If your application will access your users' secure content in ArcGIS or if you plan to distribute your application through ArcGIS Marketplace, you must use user authentication.
Implement user authentication when you want to:
- Ensure users are signed in and authenticated with their own ArcGIS account.
- Use your app user's credits to pay for their private data, content, or service transactions.
- Limit the length of time users can be signed in to your app with a temporary token.
- Distribute your app through ArcGIS Marketplace.
App authentication
App authentication grant a short-lived access token, generated via OAuth, authorizing your application to access location services, such as basemap layers, search, and routing.
Use app authentication when you want to:
- Access location services with a more secure process and a short-lived token.
- Provide access to services without requiring users to have an ArcGIS account.
Choose an authentication method
The choice of which type of authentication to implement is primarily dependent upon the resources required by your application. Also consider the strengths and limitations of the API or SDK technology on which your application is built. Your choice of authentication method is also affected by the API with which you build your application. For example, ArcGIS Runtime APIs provide an Authentication
, with helper methods and patterns to implement user authentication workflows.
Scenario | Solution |
---|---|
Your app requires access only to location services, such as the basemap layer, geocoding, or routing services. | API key authentication |
Your app allows users to view and edit private data in ArcGIS. | User authentication |
Your app is on a web server or API backend and requires access only to basemaps and geocoding. | App authentication |
Your app uses Esri Leaflet, Mapbox GL JS, or OpenLayers. | API key authentication |
Your app uses an ArcGIS API. | API key authentication or User authentication |
Authentication manager
ArcGIS Runtime APIs contain an Authentication
, which provides helper methods and patterns for implementing user authentication workflows.
The
AuthenticationManager
is a singleton class that, when enabled, will manage the user credentials for the following resources:
- ArcGIS Server resources secured using token-based authentication or using HTTP authentication. Note that only ArcGIS Server versions 10 SP 1 and greater are supported.
- Secured ArcGIS.com resources (web maps, for example).
- Secured ArcGIS Portal resources.
A credential for accessing to an ArcGIS resource can be preset by using
AuthenticationManager.AddCredential
. In this case the credential is used for any requests to the specified resources.
If a request to an ArcGIS resource returns an authorization error, the
AuthenticationManager.ChallengeHandler
, if not null, is called. This challenge handler can return the credential for accessing to the resource.
If the
IChallengeHandler
is null or if it doesn't return any credential, the authorization error is returned to the caller as if the request was executed out of the
AuthenticationManager
.
What's Next?
For more information about Security and Authentication, see the Security and Authentication chapter.