Click or drag to resize

AuthenticationManager Class

The Authentication Manager is a singleton class that, when enabled, will manage the user credentials for the following resources:
  • ArcGIS Server resources secured using token-based authentication or using HTTP authentication. Note that only ArcGIS Server versions 10 SP 1 and greater are supported.
  • Secured ArcGIS.com resources (e.g. web maps).
  • Secured ArcGIS Portal resources.
A credential for accessing to an ArcGIS resource can be preset by using AddCredential(Credential). In this case the credential is used for any requests to the specified resources.

If a request to an ArcGIS resource returns an authorization error, the ChallengeHandler, if not null, is called. This challenge handler can return the credential for accessing to the resource.

If the ChallengeHandler is null or if it doesn't return any credential, the Authorization error is returned to the caller as if the request was executed out of the AuthenticationManager.

Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.SecurityAuthenticationManager

Namespace:  Esri.ArcGISRuntime.Security
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.4.0.0
Syntax
public sealed class AuthenticationManager

The AuthenticationManager type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleChallengeHandler
Gets or sets the component that handles the authorization errors in order to get a valid credential object.
Public propertyCredentials
Gets the credentials registered by the Authentication Manager.
Public propertyStatic memberCode exampleCurrent
Gets the single AuthenticationManager instance. This is the only way to get an IdentifyManager instance.
Public propertyCode exampleOAuthAuthorizeHandler
Gets or sets the component sets the component that handles authorization by a resource owner in an oauth workflow.
Public propertyServerInfos
Gets the registered servers.
Public propertyTokenValidity
Gets or sets the default suggested lifetime of the token in minutes. This default value can be overridden for a specific credential by setting TokenValidity.
Top
Methods
  NameDescription
Public methodAddCredential
Adds a new Credential the AuthenticationManager will use for accessing the resources.
Public methodFindCredential(Uri)
Returns the token credential for the resource identified by the specified url.
Public methodFindCredential(Uri, AuthenticationType)
Returns the credential that supports the specified authentication type for the resource identified by the specified url.
Public methodFindServerInfo
Returns information about the server that is hosting at the specified url.
Public methodCode exampleGenerateCredentialAsync(Uri, GenerateTokenOptions)
Generates a token credential object asynchronously. You need to provide the service URL. This is a helper method typically called by the UI challenging the user.
Public methodCode exampleGenerateCredentialAsync(Uri, String, String, GenerateTokenOptions)
Generates a token credential object asynchronously. You need to provide the service URI, the username and the password. This is a helper method typically called by the UI challenging the user.
Public methodCode exampleGetCredentialAsync
Returns a Credential object of the specified type (credentialRequestInfo.AuthenticationType) that can be used to access the secured resource identified by the input url (credentialRequestInfo.Url). If required, the challenge method will be called and should return the expected credential object. If case of Token AuthenticationType, the user is typically challenged for a username and password which are used to generate a token. This method is typically called internally when a request fails due to an "invalid credentials" error.
Public methodCode exampleRegisterServer
Register secure servers and the token endpoints. The Authentication Manager makes its best guess to determine the location of the secure server and token endpoint so in most cases calling registerServers is not necessary. However if the location of your server or token endpoint is non-standard use this method to register the location. Additionally if portal uses the OAuth authentication, it needs to be registered by this method.
Public methodRemoveCredential
Removes an existing credential so the challenge handler will be called the next time an access to the resources is needed.
Top
Remarks
Most generally the ChallengeHandler displays the UI allowing the user to enter the username/password for accessing the resource. Unlike for WinStore application, the API doesn't provide any default UI for WinPhone or Desktop. However, a default challenge handler is set for managing the access though OAuth when the OAuthAuthorizeHandler is set.
See Also
Additional Examples
Hyperlink to ExampleDescription
AuthorMapThis sample demonstrates how to author and save a map as an ArcGIS portal item (web map). Saving a map to arcgis.com requires an ArcGIS Online login.
OAuthThis sample demonstrates how to authenticate with ArcGIS Online (or your own portal) using OAuth2 to access a secure web map (or the secured layers it contains). Accessing secured items requires a login on the portal (an ArcGIS Online account, for example).
SearchPortalMapsThis sample demonstrates searching a portal for web maps and loading them in the map view. You can search ArcGIS Online public web maps using tag values or browse the web maps in your account. OAuth is used to authenticate with ArcGIS Online to access items in your account.
TokenSecuredChallengeThis sample demonstrates how to authenticate with ArcGIS Server using ArcGIS Tokens to access a secure service. Accessing secured services requires a login that's been defined on the server.