Security and authentication
Authentication is used to keep corporate and network data secure and ensure that only valid, authenticated users can access private information. Your application or its users are required to authenticate their credentials through a qualified, compatible ArcGIS platform such as ArcGIS Online or ArcGIS Enterprise whenever attempting to:
- Access private user or corporate-owned information.
- Create, edit, or publish content.
- Access premium (payment-secured) web content or services.
You must implement an authentication method in order to grant your app's users access to secured resources. The authentication method you decide to implement might vary based upon the resources required by your application. Esri's preferred authentication methods are:
ArcGIS identity (OAuth 2.0): This method obtains user credentials and authentication through an ArcGIS platform sign-on, and the platform responds with an OAuth 2.0
access_tokento the client app. The app uses this
tokenin all subsequent requests to the platform. This is the recommended method, and is most commonly used with ArcGIS Online and ArcGIS Enterprise.
API key: This unique identifier is used to authenticate a user, developer, or calling program to an API, although most typically used to authenticate a project rather than a human user.
When your app requires access to user content or if you are distributing your app through ArcGIS Marketplace, you should implement OAuth 2.0 to obtain an ArcGIS identity. This allows individual users to authorize your app to use the content and services to which that user has been granted access.
- Users sign in with their ArcGIS Online or ArcGIS Enterprise accounts via OAuth 2.0
- Tokens expire and require re-authentication or a refresh token call
- Tokens can be short-lived or long-lived depending on use cases
- Cross-functional: Can be used with browsers, devices, or servers
- Tokens can be used to access both:
- Location services
- Any ArcGIS Online or Enterprise content shared with the user
|Preferred approach for secure build / authentication||App user MUST have either an ArcGIS Online or Enterprise account|
|App build method that works with both ArcGIS Online and Enterprise content|
|More secure than API keys|
|Most secure method for accessing location services and user content|
|Paid location services consumption is charged to the ArcGIS identity owner, not the app developer.|
Learn more about ArcGIS identity.Learn more about ArcGIS identity
API keys allow access to location services with a permanent key that can be restricted to specific services and included in public applications.
- Permanent access keys
- Used for accessing specific location services
- Restricted to specific referrer headers
- ArcGIS Developer accounts can use API keys to access their own (read only) private content
|Developers can quickly write apps using API keys that consume location services||Cannot access private content from an ArcGIS Online organization|
|Can be used by apps that utilize sign-in / authentication services outside of ArcGIS|
The choice of which type of authentication to implement is mostly 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.
In general, it is recommended that you use:
- API keys if your application needs to access location services from Esri.
- ArcGIS identity if users of your application will authenticate with their ArcGIS Online or ArcGIS Enterprise accounts.
Your choice of authentication method is also affected by the API with which you build your application. ArcGIS APIs contain a built in
AuthenticationManager, which provide helper methods and patterns for implementing ArcGIS identity workflows.
ArcGIS APIs contain a built authentication manager, which provides helper methods and patterns for implementing ArcGIS identity workflows.
AuthenticationManager class allows you to manage authentication/security related tasks.
It emits the authenticationChallenge signal whenever an authentication or security issue is encountered anywhere in the API.
The following challenges can be raised by the
AuthenticationChallengeType::UsernamePassword- Challenges needing username and/or password authentication.
AuthenticationChallengeType::OAuth- Challenges needing an OAuth authorization code.
AuthenticationChallengeType::ClientCertificate- Challenges needing a client certificate to be provided.
AuthenticationChallengeType::SslHandshake- Challenges needing a response to certain SslError errors, usually an untrusted host due to a self-signed certificate.
To handle authentication challenges in the UI automatically in QML, import the
Esri.ArcGISRuntime.Dialogs module and declare the
AuthenticationView component. After registering the
AuthenticationManager type with QML, populate the authenticationManager property of the view with the
AuthenticationManager::instance() exposed from C++ to QML. You can register the
AuthenticationManager as a QML type with the following syntax:
qmlRegisterUncreatableType<AuthenticationManager>("Esri.TestNamespace", 1, 0, "AuthenticationManager", "AuthenticationManager is uncreateable");
To see a full example of using the
AuthenticationView with the
AuthenticationManager, please see the token authentication sample.
It also contains an instance of a
CredentialCache which maintains a cache of credentials, in memory, that have been previously used to satisfy authentication challenges. This allows a credential to be reused where appropriate, and prevents unnecessary or duplicate challenges from being issued while accessing secure resources from the same security realm. Caching happens automatically if
isCredentialCacheEnabled() is true.
For more information about Security and Authentication, see the Security and Authentication chapter.