Auth0 allows you to quickly add authentication and access user profile information in your application. This guide
demonstrates how to integrate Auth0 with a Flutter application using the Auth0 Flutter SDK.This quickstart assumes you already have a Flutter application up and running. If not, check out the Flutter “getting
started” guides to get started with a simple app.You should also be familiar with the Flutter command line tool.
This concludes our quickstart tutorial, but there is so much more to explore. To learn more about what you can do with Auth0, check out:
The Flutter SDK currently only supports Flutter applications running on Android, iOS, or Web platforms.
1
Configure Auth0
When you signed up for Auth0, a new application was created for you, or you could have created a new one. You
will need some details about that application to communicate with Auth0. You can get these details from the Application
Settings section in the Auth0 dashboard.
You need the following information:

When using the Default App with a Native or Single Page Application, ensure to update the Token
Endpoint Authentication Method to
None
and set the Application Type to either
SPA
or Native
.- Domain
- Client ID
If you download the sample from the top of this page, these details are filled out for you.
Configure Callback URLs
A callback URL is a URL in your application where Auth0 redirects the user after they have authenticated. The callback URL for your app must be added to the Allowed Callback URLs field in your Application Settings. If this field is not set, users will be unable to log in to the application and will get an error.If you are following along with the sample project you downloaded from the top of this page, you should
set the Allowed Callback URL to
http://localhost:3000
.Configure Logout URLs
A logout URL is a URL in your application that Auth0 can return to after the user has been logged out of the authorization server. This is specified in thereturnTo
query parameter. The logout URL for your app
must be added to the Allowed Logout URLs field in your Application Settings. If this field is not set, users will be
unable to log out from the application and will get an error.If you are following along with the sample project you downloaded from the top of this page, the logout
URL you need to add to the Allowed Logout URLs field is
http://localhost:3000
.Configure Allowed Web Origins
You need to add the URL for your app to the Allowed Web Origins field in your Application Settings. If you don’t register your application URL here, the application will be unable to silently refresh the authentication tokens and your users will be logged out the next time they visit the application, or refresh the page.If you are following along with the sample project you downloaded from the top of this page, you should
set the Allowed Web Origins to
http://localhost:3000
.2
Install the Auth0 Flutter SDK
Add the Auth0 Flutter SDK into the project:Add the following script tag to your
index.html
page:3
Add login to your application
Universal Login is
the easiest way to set up authentication in your application. We recommend using it for the best experience, best
security, and the fullest array of features.Integrate Auth0 Universal Login in your Flutter Web app by using the When a user logs in, they are redirected back to your application. You are then able to access the ID and access
tokens for this user by calling
Auth0Web
class. Redirect your
users to the Auth0 Universal Login page using loginWithRedirect()
.You will normally need to specify the
redirectUrl
parameter to
loginWithRedirect
. Omitting this will cause Auth0 to use the default login route, which is not configured by default.onLoad
during startup and handling the credentials that are given to
you:Checkpoint
Add a button to your app that callsloginWithRedirect()
and logs the user into your app.
Verify that you are redirected to Auth0 for authentication and then back to your application.Verify that you can access credentials
as a result of calling onLoad
and that
you’re able to access the ID and access tokens.4
Add logout to your application
To log users out, redirect them to the Auth0 logout endpoint to clear their login session by calling the Auth0
Flutter SDK
logout()
. Read
more about logging out of Auth0.You will normally want to specify
returnToUrl
when calling logout
, otherwise
Auth0 will default to the first URL in the Allowed Logout URLs list.Checkpoint
Add a button to your app that callslogout()
and logs the user out of your application. When
you select it, verify that your Flutter app redirects you to the logout endpoint and back again. You
should not be logged in to your application.5
Show user profile information
The user profile automatically retrieves user profile properties for you when the page loads, and can be accessed
and stored by calling
onLoad
during application startup. The returned object from onLoad
contains a user
property with all the user profile properties. This is internally populated by
decoding the ID token.Checkpoint
Log in and inspect theuser
property on the result. Verify the current user’s profile
information, such as email
or name
.Next Steps
Excellent work! If you made it this far, you should now have login, logout, and user profile information running in your application.This concludes our quickstart tutorial, but there is so much more to explore. To learn more about what you can do with Auth0, check out:
- Auth0 Dashboard - Learn how to configure and manage your Auth0 tenant and applications
- auth0-flutter SDK - Explore the SDK used in this tutorial more fully
- Auth0 Marketplace - Discover integrations you can enable to extend Auth0’s functionality