How to access user information
You can connect your map.apps for Developers project to an Identity Service instance. Doing this enables you to access user information from ArcGIS Online, an ArcGIS Enterprise portal or a Keycloak instance while developing bundles.
Checklist
-
A project based on map.apps for Developers version 4.15.0 or higher.
-
An Identity Service instance set up and running. Check the Identity Service documentation for more information.
-
map.apps for Developers and Identity Service both running under HTTPS. Alternatively, both can run under
localhostfor development purposes.
Step 1: Connect the Identity Service
First, you need to configure map.apps for Developers to connect to the Identity Service.
-
Open the
application.propertiesfile of your map.apps for Developers project. -
Add the following required properties to connect to the Identity Service as described below.
# Enable the Identity Service integration security.mode=IDENTITY # Base URL of the Identity Service security.login.base=http://localhost:8080 # This has to be the URL of the ArcGIS Online organization or # the URL of the ArcGIS Enterprise portal # The value must match the configuration from the Identity Service # security.oauth.provider.arcgis.url esri.api.arcgisPortalUrl=https://myhost.example.com/portal # Necessary to send cookie via proxy proxy.allowedServerUrls=http://localhost:8080/**,trusted:true;Replace the URLs with the actual URLs of your Identity Service and your ArcGIS Online organization or ArcGIS Enterprise portal.
-
If Identity Service runs on a host in a different domain than map.apps for Developers, you need to add the Identity Service hostname to the property
cors.request.trustedServerslike this:# (Optional) Add the Identity Service as 'trustedServer', # so that the cookie is also sent for cross domain requests cors.request.trustedServers=https://identity.example.com -
Save the file and restart the development server.
-
If you use a fully qualified hostname instead of
localhostto access map.apps for Developers in your browser, then you may need to add the hostname to the propertysecurity.login.redirect.trusted.hostsat the Identity Service configuration. See the Identity Service documentation for more information about that property.
Step 2: Enable authentication in the app
To make use of authentication in your map.apps for Developers app, you need to prepare your app accordingly.
-
Open the
app.jsonfile of your project. -
Add the authentication bundle to your app like this:
... "allowedBundles": [ ..., "authentication" ] }, ... -
Save the file and reload the app in your browser.
You should now see a login button in the top right corner of the app. When clicking the button, the browser redirects you to the Identity Provider as specified in the Identity Service configuration. On successful login, the browser redirects you back to your app showing your username in the top right corner.