loginWithPopup method
Opens a popup with the /authorize
URL using the parameters provided as
parameters.
Random and secure state and nonce parameters will be auto-generated. If the response is successful, results will be valid according to their expiration times.
Note: This method should be called from an event handler that was triggered by user interaction, such as a button click. Otherwise the popup will be blocked in most browsers.
Additional notes:
audience
relates to the API Identifier you want to reference in your access tokens. See API settings to learn more.scopes
defaults toopenid profile email
. You can override these scopes, butopenid
is always requested regardless of this setting.- If you want to log into a specific organization, provide the
organizationId
. ProvideinvitationUrl
if a user has been invited to join an organization. - Arbitrary
parameters
can be specified and then picked up in a custom Auth0 Action or Rule.
Using a custom popup
To provide your own popup window, create it using the window.open()
HTML API and set popupWindow
to the result. You may want to do this
if certain browsers (like Safari) block the popup by default; in this
scenario, creating your own and passing it to loginWithPopup()
may fix
it.
final popup = window.open('', '', 'width=400,height=800');
final credentials = await auth0Web.loginWithPopup(popupWindow: popup);
Note: This requires that dart:html
be imported into the plugin
package, which may generate the warning
'avoid_web_libraries_in_flutter'.
Implementation
Future<Credentials> loginWithPopup(
{final String? audience,
final String? organizationId,
final String? invitationUrl,
final int? maxAge,
final Set<String>? scopes,
final dynamic popupWindow,
final int? timeoutInSeconds,
final Map<String, String> parameters = const {}}) =>
Auth0FlutterWebPlatform.instance.loginWithPopup(PopupLoginOptions(
audience: audience,
organizationId: organizationId,
invitationUrl: invitationUrl,
scopes: scopes ?? {},
idTokenValidationConfig: IdTokenValidationConfig(maxAge: maxAge),
popupWindow: popupWindow,
timeoutInSeconds: timeoutInSeconds,
parameters: parameters));