Skip to content

Most ArcGIS portals contain a considerable amount of content that is not public, but is instead secured and shared with the entire organization or specific groups. To access this secured content, users must authenticate with the portal.

The portal object will have access to all the secure content for which the user has access privileges and can be used to find out more information about the user, such as the user's full name (instead of the account user name). Additionally, information about the organization such as the name, banner image, description, and so on, can be read. Apps often make use of this information when a user connects to a specific portal, to show the user organization branding and context.

Typically, the portal object with the authenticated user is cached and used throughout the app session, to provide the app with a view of a portal that is centered around a single user. When the app is restarted, the credential must be reinstated, or the user must repeat the authentication process.

Access tokens

Accessing secured content requires an access token. The most common access tokens in ArcGIS are OAuth 2.0 tokens and API keys. For information on authentication in ArcGIS Maps SDK for Qt, see Security and Authentication in this guide. For steps to obtain user authentication or API key credentials, see Create developer credentials.

Accessing secured content in ArcGIS Online requires that you authenticate with the portal. You can do this by creating a Portal instance, passing true for the loginRequired parameter. Then your app must apply the access token.

The workflow for accessing secured content is as follows:

  1. Apply the access token in your app code.
  2. Create a Portal instance, passing true for the loginRequired parameter.

Access using OAuth

When accessing secured content using OAuth 2.0 credentials, the user's ArcGIS account must be of the correct user type and have the necessary privileges.

There are several configuration steps that are needed utilize OAuth in Qt in your source code file, including: downloading the ArcGIS Maps SDK for Qt Toolkit, configuring the *.pro file, adding code to the main.cpp file, and consuming the Authenticator component in the *.qml file. Detailed instructions for these steps can be found by completing the Display a map tutorial.

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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
    // Define the Redirect URL string obtained when creating the OAuth credentials.
    // TODO: You need to replace the "REDIRECT_URL" with your own valid string,
    // ex: "urn:ietf:wg:oauth:2.0:oob"
    const auto qStringRedirectUrl = QString{"REDIRECT_URL"};

    // Define the URL of the portal to authenticate with.
    // TODO: You need to replace the "PORTAL_URL" with your own valid string,
    // ex: "https://www.arcgis.com/"
    const QUrl qUrlPortal = QUrl{"PORTAL_URL"};

    // Define a unique identifier associated with an application registered with the
    // portal that assists with client/server OAuth authentication.
    // TODO: You need to replace the "CLIENT_ID" with your own valid string.
    const QString qStringClientId = QString{"CLIENT_ID"};

    // Create a new OAuth user configuration using: the Url to mapping web service, the Client ID
    // string, and the Redirect Url string.
    auto* oAuthUserConfiguration = new OAuthUserConfiguration(qUrlPortal, qStringClientId, qStringRedirectUrl, this);

    // Call the Qt Toolkit OAuthUserConfigurationManager static `addConfiguration`
    // method to use the OAuth dialog. This will tell the Authenticator to use OAuth
    // for the provided configuration.
    Toolkit::OAuthUserConfigurationManager::addConfiguration(oAuthUserConfiguration);

The code is the same whether connecting to ArcGIS Online or ArcGIS Enterprise. The only difference is the URL. For information on accessing ArcGIS Enterprise, see the Getting started using ArcGIS Enterprise.

Access using an API key

An API key must have the required privileges for the content being accessed. You can apply the key to the ArcGISRuntimeEnvironment class so it's available across the entire application. For information on using API Keys in your app, see Security and authentication in this guide.

For an example of API key use in an app, see any of the ArcGIS Maps SDK for Qt tutorials, such as Display a map.

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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
    // Set the API Key.
    Esri::ArcGISRuntime::ArcGISRuntimeEnvironment::setApiKey("YOUR_ACCESS_TOKEN");

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