Security and authentication

ArcGIS supports secure access to location services and private data. It ensures that only valid, authorized users and services access protected information. In order to access secure ArcGIS resources, you need an access token. To get an access token, you need to choose a type of authentication and implement an authentication workflow in your app. The type of authentication you use will depend on the security and access requirements of your app.

There are three types of authentication that you can use to get 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 credentials, 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 credentials, authorizing your application to access location services.

To make authenticated requests to services, you need to set the token parameter to an access token.

For more information, see the Security and authentication guide.

Choose a type of authentication

The following considerations can help determine which type of authentication to implement:

  • Access to resources—Your app can access location services using API key authentication, User authentication, or App authentication. To access private data hosted in ArcGIS Online or ArcGIS Enterprise, or content that requires an ArcGIS Online subscription, your app needs an authenticated user to sign in with their account.

  • User experience—If you don't want to make users log in, your app can access location services using API key authentication or App authentication. In this case, users will not need to have an ArcGIS account in order to use your app.

  • Usage charges—If you want service usage to be charged to the user's account, your app must request that the user log in. When using API key authentication or App authentication, all access to services from your app will be charged to your ArcGIS account.

You might also need to consider the level of security required for your app, how your app will be distributed, and your available ArcGIS products and accounts.

ScenarioSolution
Your app requires access to location services only, you don't want to make users log in, and you are willing to pay for all charges incurred from usage of the app.API key authentication or App authentication
Your app requires access to location services only and you want usage charged to the user.User authentication
Your app needs to access content that requires an ArcGIS Online subscription.User authentication
Your app needs to access private hosted data on your ArcGIS Location Platform account.API key authentication or App authentication
Your app allows users to view and edit private data hosted in ArcGIS Online or ArcGIS Enterprise.User authentication
You plan to distribute your app through ArcGIS Marketplace.User authentication

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.
Learn more about API key authentication

Use API key access tokens

An API key, can be used to authorize access to specific ArcGIS location services, and, with an ArcGIS Location Platform account, private content, items, and limited client referrers. Go to the Create an API key tutorial to obtain a new access token.

If you set the access token on the ArcGISRuntimeEnvironment, all requests made by your app will be authorized using this token. You will be able to view the app's usage telemetry on the ArcGIS Location Platform.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
    ArcGISRuntimeEnvironment::setApiKey("YOUR_ACCESS_TOKEN");

You can also set the access token on any class that implements ApiKeyResource. 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 used by your app.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
    // Create a new ArcGIS basemap and apply an access token.
    Basemap* basemap = new Basemap(BasemapStyle::ArcGISTopographic, this);
    basemap->setApiKey("YOUR_ACCESS_TOKEN");

    // Create a new map with the basemap.
    m_map->setBasemap(basemap);

Classes that implement ApiKeyResource include:

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.

Services that your app accesses with 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.
Learn more about user authentication

App authentication

App authentication grants a short-lived access token, generated via OAuth 2.0, 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.
Learn more about app authentication

Authentication manager

This API contains an AuthenticationManager, available from the ArcGISRuntimeEnvironment, that manages all user authentication when your application connects to secured resources. It provides a central place to configure the authentication challenge handlers and credential stores.

The 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 AuthenticationManager:

  • 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.

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.

The easiest way to handle authentication challenges in the UI is to use the AuthenticationView component available in the ArcGIS Maps SDK for Qt Toolkit GitHub repo.

The Access services with OAuth 2.0 tutorial provides a detailed, step-by-step, example of how to create a Qt Creator project to authenticate a user to access a secure ArcGIS service with OAuth 2.0.

There is also an example of using the AuthenticationView with the AuthenticationManager in the Token authentication sample.

What's Next?

For more information about Security and Authentication, see the Security and Authentication chapter.

Tutorials

Samples

Portal user info

Integrated Windows authentication

Token authentication

Create and save a map

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.