Userfront class
A Flutter/Dart interface for Userfront.
Enables authentication on a mobile device, and handles storage, retrieval, and use of tokens
Properties
- accessToken → String?
-
The user's Userfront access token. Automatically attached to Userfront
API requests made via
api.get,api.post,api.putandapi.delete.no setter - api ↔ UserfrontApi
-
A UserfrontApi instance, mediating interaction with the Userfront API
and refreshing the accessToken as needed.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
- idToken → String?
-
The user's Userfront ID token. Contains user information. Not currently
used internally.
no setter
- isLoggedIn → bool
-
Whether the user appears to be logged in: there is a locally valid
accessToken OR refreshToken. To be confident that the user does have
a valid session, first call refresh to refresh the tokens - otherwise,
it's possible that the user's refreshToken was remotely invalidated.
no setter
- mode → String
-
The mode: 'test' or 'live'. Set to 'live' by default, updated to
'test' if the server indicates it's test mode.
no setter
- pkcePair → PkcePair
-
The current
PkcePairto use for a browser-based logon. A new pair is generated each time an auth URL is generated.no setter - refreshToken → String?
-
The user's Userfront refresh token. Automatically used to refresh the
accessToken as needed.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tenantId → String
-
The account-level tenant's tenantId
final
Methods
-
createAuthUri(
Uri uri) → Uri -
Given a Uri
uri, returns the Uri with query parameters set correctly for mobile logon with the @userfront/core browser library or Userfront toolkit forms. The URL should point to a browser-based logon page. From there, the Userfront Core JS library will handle the logon flow, and will redirect back to your specific mobile after-auth URL to finish the logon by calling finishAuth. -
createAuthUrl(
String url) → String -
Given a
urlstring, returns the URL with query parameters set correctly for mobile logon with the @userfront/core browser library or Userfront toolkit forms. The URL should point to a browser-based logon page. From there, the Userfront Core JS library will handle the logon flow, and will redirect back to your specific mobile after-auth URL to finish the logon by calling finishAuth. -
finishAuth(
String authorizationCode) → Future< Map< String, dynamic> > -
Given an
authorizationCodeprovided as a query parameter to an incoming link, exchange it for the accessToken, idToken and refreshToken from the Userfront API. -
logout(
) → Future< void> - Clear the local accessToken, idToken and refreshToken. If either accessToken or refreshToken are valid, calls the Userfront API's /auth/logout endpoint as well.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
) → Future< bool> - Force the accessToken to be refreshed, if a valid refreshToken is present. It's a good practice to refresh at the beginning of the user session if using a stored session.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
init(
String tenantId, String origin, [TokenStore? tokenStore, UserfrontApi? api]) → Future< Userfront> -
Creates an initializes a Userfront client instance for the given
tenantIdandorigin. Setoriginequal to a configured live domain to use live mode, or to anything else to use test mode. ThetokenStoreandapiparameters allow changing these dependencies for automated testing - clients should not pass in these parameters, as the defaults are the correct dependencies for use with the Userfront API.