PlatformWebAuthenticationSession class abstract

A session that an app uses to authenticate a user through a web service.

It is implemented using ASWebAuthenticationSession on iOS 12.0+ and MacOS 10.15+ and SFAuthenticationSession on iOS 11.0.

Use an PlatformWebAuthenticationSession instance to authenticate a user through a web service, including one run by a third party. Initialize the session with a URL that points to the authentication webpage. A browser loads and displays the page, from which the user can authenticate. In iOS, the browser is a secure, embedded web view. In macOS, the system opens the user’s default browser if it supports web authentication sessions, or Safari otherwise.

On completion, the service sends a callback URL to the session with an authentication token, and the session passes this URL back to the app through a completion handler. PlatformWebAuthenticationSession ensures that only the calling app’s session receives the authentication callback, even when more than one app registers the same callback URL scheme.

NOTE: Remember to dispose it when you don't need it anymore.

NOTE for iOS: Available only on iOS 11.0+.

NOTE for MacOS: Available only on MacOS 10.15+.

Officially Supported Platforms/Implementations:

  • iOS
  • MacOS
Inheritance
  • Object
  • PlatformInterface
  • PlatformWebAuthenticationSession
Implemented types

Properties

callbackURLScheme String?
The custom URL scheme that the app expects in the callback URL.
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
ID used internally.
no setter
initialSettings WebAuthenticationSessionSettings?
Initial settings.
no setter
onComplete WebAuthenticationSessionCompletionHandler?
A completion handler the session calls when it completes successfully, or when the user cancels the session.
no setter
params PlatformWebAuthenticationSessionCreationParams
The parameters used to initialize the PlatformWebAuthenticationSession.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url WebUri
A URL with the http or https scheme pointing to the authentication webpage.
no setter

Methods

cancel() Future<void>
Cancels the web authentication session.
canStart() Future<bool>
Indicates whether the session can begin.
create({required WebUri url, String? callbackURLScheme, WebAuthenticationSessionCompletionHandler? onComplete, WebAuthenticationSessionSettings? initialSettings}) Future<PlatformWebAuthenticationSession>
Used to create and initialize a session.
dispose() Future<void>
Disposes the web authentication session.
override
isAvailable() Future<bool>
Returns true if ASWebAuthenticationSession or SFAuthenticationSession is available. Otherwise returns false.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
start() Future<bool>
Starts the web authentication session.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

debugLoggingSettings DebugLoggingSettings
Debug settings.
getter/setter pair