Authenticator class

The Authenticator widget handles authentication challenges.

Overview

A user interface is displayed when network and ArcGIS authentication challenges occur.

Features

The Authenticator will handle many different types of authentication, for example:

  • ArcGIS authentication (token and OAuth)
  • Integrated Windows Authentication (IWA)
  • Client Certificate (PKI)
  • Identity-Aware Proxy (IAP)
  • If credentials were persisted to the keychain, the authenticator will use those instead of requiring the user to re-enter credentials.

Usage

An Authenticator can be placed anywhere in your widget tree, though it makes the most sense to use it as the parent of the ArcGISMapView or ArcGISSceneView widget. It will then handle authentication challenges from loading network resources.

To use OAuth, provide one or more OAuthUserConfigurations in the Authenticator.oAuthUserConfigurations parameter. Otherwise, the user will be prompted to sign in using a username and password to obtain a TokenCredential.

If a service is protected by an Identity-Aware Proxy (IAP), provide its IapConfiguration in the Authenticator.iapConfigurations parameter.

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Authenticator(
        oAuthUserConfigurations: [
          OAauthUserConfiguration(
            portalUri: Uri.parse('https://www.arcgis.com'),
            clientId: 'YOUR-CLIENT-ID',
            redirectUri: Uri.parse('YOUR-REDIRECT-URL'),
          ),
        ],
        iapConfigurations: [
          IapConfiguration.fromJsonString(yourConfigurationJson),
        ],
        child: ArcGISMapView(
          controllerProvider: () => _mapViewController,
        ),
      ),
    );
  }

During application sign-out, you should revoke all tokens and clear all credentials from the credential stores. Use Authenticator.revokeOAuthTokens and Authenticator.invalidateIapCredentials as required, then Authenticator.clearCredentials. In addition, consider also clearing the HTTP cache, using ArcGISEnvironment.httpClient.cache.evictAll(), to prevent cached responses from being accessed without the credentials that were used to originally fetch them.

More information

To learn more about using OAuth with ArcGIS accounts, see: https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/

To configure OAuth for use in your ArcGIS Maps SDK for Flutter app, see: https://developers.arcgis.com/flutter/install-and-set-up/#enabling-user-authentication

Inheritance

Constructors

Authenticator({Key? key, Widget? child, List<OAuthUserConfiguration> oAuthUserConfigurations = const [], List<IapConfiguration> iapConfigurations = const []})
Creates an Authenticator widget with the optional child Widget and optional oAuthUserConfigurations and iapConfigurations.
const

Properties

child Widget?
An optional child widget.
final
hashCode int
The hash code for this object.
no setterinherited
iapConfigurations List<IapConfiguration>
The list of IAP configurations to use for authenticating with an Identity-Aware Proxy (IAP).
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
oAuthUserConfigurations List<OAuthUserConfiguration>
The list of OAuth configurations to use for authentication.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<Authenticator>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

clearCredentials() Future<void>
Clear all credentials from the credential store.
invalidateIapCredentials() Future<void>
Invalidate all IAP credentials. This will launch a logout workflow in the system browser. The returned Future completes when the logout process is finished.
revokeOAuthTokens() Future<void>
Revoke all OAuth tokens. The returned Future completes when all tokens have been successfully revoked.