Authenticate with ArcGIS Online (or your own portal) using OAuth2 to access secured resources (such as private web maps or layers).
Your app may need to access items that are only shared with authorized users. For example, your organization may host private data layers or feature services that are only accessible to verified users. You may also need to take advantage of premium ArcGIS Online services, such as geocoding or routing services, which require a named user login.
When you run the sample, the app will load a web map which contains premium content. You will be challenged for an ArcGIS Online login to view the private layers. Enter a user name and password for an ArcGIS Online named user account (such as your ArcGIS for Developers account). If you authenticate successfully, the traffic layer will display, otherwise the map will contain only the public basemap layer.
- Create a
OAuthUserConfiguration
specifying the portal URL, app id, and redirect URL. - Set the
AuthenticationManager
'sOAuthUserConfigurations
with the newOAuthUserConfiguration
. - Set the
AuthenticationManager
'sOAuthAuthorizeHandler
to an instance of a class which implementsIOAuthAuthorizationHandler
. - Load a map with premium content requiring authentication to automatically invoke the authentication handler.
- AuthenticationManager
- OAuthTokenCredential
- OAuthUserConfiguration
- PortalItem
The workflow presented in this sample works for most SAML based enterprise (IWA, PKI, Okta, etc.) & social (facebook, google, etc.) identity providers for ArcGIS Online or Portal. For more information click here.
On UWP, some authentication workflows that don't support WebAuthenticationBroker
may require a custom IOAuthAuthorizeHandler
.
For additional information on using Oauth in your app, see the Mobile and Native Named User Login topic in our guide.
authentication, cloud, credential, OAuth, OAuth2, portal, security