YOUR_PACKAGE_ID
is your application’s package ID. This can be
found and configured in the appId
field in your capacitor.config.ts
file. See
Capacitor’s Config schema for more info.YOUR_PACKAGE_ID://{yourDomain}/capacitor/YOUR_PACKAGE_ID/callback
YOUR_PACKAGE_ID://{yourDomain}/capacitor/YOUR_PACKAGE_ID/callback
capacitor://localhost, http://localhost
for iOS and Android respectively.AuthModule
, a module that contains all the services required for the SDK to
function. This module should be registered with your application and be configured with your Auth0 domain and
Client ID.The AuthModule.forRoot
function takes the following configuration:domain
: The domain
value present under the **Settings **of the application you
created in the Auth0 Dashboard, or your custom domain if you are using Auth0’s custom domains feature.clientId
: The Client ID value present under the **Settings **of the application you created
in the Auth0 Dashboard.useRefreshTokens
: To use auth0-angular with Ionic on Android and iOS, it’s required to enable
refresh tokens.useRefreshTokensFallback
: To use auth0-angular with Ionic on Android and iOS, it’s required to
disable the iframe fallback.authorizationParams.redirect_uri
: The URL to redirect your users after they authenticate with
Auth0.cacheLocation
to localstorage
when configuring the SDK, but please be aware of
the risks of
storing tokens in localstorage. Also, localstorage should be treated as transient in
Capacitor app as the data might be recovered unexpectedly in certain circumstances. Please read the guidance on storage in the Capacitor docs.Additionally, the SDK has the ability to use a custom cache implementation to store tokens, if
you have a requirement to use a more secure and persistent storage mechanism.Note that we recommend against using Capacitor’s Storage plugin to store tokens, as this is
backed by UserDefaults and SharedPreferences on iOS and Android respectively. Data stored using
these APIs is not encrypted, not secure, and could also be synced to the cloud.openUrl
parameter on the loginWithRedirect
function to use Browser.open
so that the URL is
opened using the device’s system browser component (SFSafariViewController on iOS, and Chrome
Custom Tabs on Android).loginWithRedirect
method uses window.location.href
to
navigate to the login page in the default browser application on the user’s device rather than the
system browser component appropriate for the platform. The user would leave your application to
authenticate and could make for a suboptimal user experience.loginWithRedirect
function tells the SDK to initiate the login flow, using the
Browser.open
function to open the login URL with the platform’s system browser component by
setting the openUrl
parameter. This provides a way for your user to log in to your
application. Users redirect to the login page at Auth0 and do not receive any errors.appUrlOpen
event must be handled within your app. You can call the
handleRedirectCallback
method from the Auth0 SDK to initialize the authentication state.You can only use this method on a redirect from Auth0. To verify success, check for the presence of the
code
and state
parameters in the URL.The Browser.close()
method should close the browser when this event is raised.Note that the appUrlOpen
event callback is wrapped in ngZone.run
. Changes to
observables that occur when handleRedirectCallback
runs are picked up by the Angular app. To learn
more, read Using
Angular with Capacitor. Otherwise, the screen doesn’t update to show the authenticated state after log in.YOUR_PACKAGE_ID
as a URL scheme for your chosen
platform. To learn more, read Defining a Custom URL Scheme for iOS, or Create Deep Links to App Content for Android.appUrlOpen
to your application’s App
component and log in. The browser
window should close once the user authenticates and logs in to your app.logout
, and pass your redirect URL back as the
logoutParams.returnTo
parameter.openUrl
parameter to a callback that uses the Capacitor browser plugin to open the URL
using Browser.open
.openUrl
when calling logout
, the
SDK redirects the user to the logout URL using the default browser application on the device, which
provides a suboptimal user experience.returnTo
parameter. Make sure users are no longer logged in to
your application.user$
property
exposed by AuthService
.