Flutter & Node.js Quickstart
This is a quickstart guide to help you integrate Descope with your Flutter & Node.js application. Follow the steps below to get started.
Include the Descope Flutter Package
Incorporate the Descope Flutter SDK as a dependency. Run the following command:
(iOS Only) Set minimum global platform version to 13.0
- Navigate to
ios/Podfile
- Uncomment
platform :ios, '11.0'
- Set the version to
13.0
(Android Only) Set minimum global platform version to 24
- Navigate to
android/app/build.gradle
- Replace
minSdkVersion flutter.minSdkVersion
withminSdkVersion 24
Import the Flutter SDK
Proceed to import the Descope Flutter dependency.
Initialize Descope with Custom Project ID
Set up Descope in main.dart
using the Descope Project ID found on your Descope project page. This is needed to activate the SDK.
Note
Optionally, add the baseUrl
parameter if using a CNAME in your Descope project (e.g., https://auth.company.com
).
Define and Host Your Flow
Your Descope console provides customizable, predefined authentication flows which are hosted for you. You can also host the flow yourself. You'll use the url of the hosted flow later in your code. If you are deploying to Web, you can set the flow id and container css in the options here as well. For more on web flows set up, read about it in our SDK README.
(Android Only) Configure App Links, Activity & Routing
For Android (iOS works with just a flow url), follow the instructions in our SDK README to establish App Links, create an Activity, and manage routing.
Launch your Flow
Use the flow 'start' function to initiate authentication with a custom flow (URL from step 6). For Android, add the deep link (URL from step 7).
Note
If you're using Magic Link authentication, additional setup is required as mentioned in our README.
Leverage Flutter SDK's Session Management Functions
Descope offers the Session Manager to confirm user authentication or access user details like email, userId, etc. Personalize the user experience with:
user
- Access user attributes (email, name, etc.)logout
- Revoke and clear active sessionrefreshToken?.isExpired
- Check if the user is authenticated
For more specifics on implementing Session Management, check out our Mobile Session Validation page.
For backend Session Validation, continue reading!
Import and Setup Backend SDK
You'll need import and setup all of the packages from the SDK.
If you're using a CNAME with your Descope project, make sure to include baseUrl
in the parameters (e.g. {baseUrl : 'https://api.descope.com'}
) when you initialize DescopeClient
.
Implement Session Validation
You will need to then fetch the session token from the Authorization header of each request, and use the SDK to validate the token.
The frontend SDK will store the session token in either a cookie or your browser's local storage. If using a cookie, the token will be sent to your app server automatically with every request.
Congratulations
Now that you've got the authentication down, go focus on building out the rest of your app!
Checkpoint
Your application is now integrated with Descope. Please test with sign-up or sign-in use case.
Customize
Now that you have the end-to-end application working, you can choose to configure and personalize many different areas of Descope, including your brand, style, custom user authentication journeys, etc. We recommend starting with customizing your user-facing screens, such as signup and login.