The Kinde Starter Kit for Flutter SDK.
To get started set up an account on Kinde.
This SDK is suitable for:
- Flutter 3.10.0 or later.
- Dart 3.0.6 or later.
Follow the installation instructions for your chosen OS to install dependencies
- Clone the repository to your machine:
https://github.com/abdullahihsan3/flutter-starter-kit.git
- Go into the project:
cd flutter-starter-kit
- Install the dependencies:
flutter pub get
# [iOS] Install iOS dependencies
cd ios
pod install
-
In Kinde, go to Settings > Applications.
-
Select View details on your app.
-
Scroll down to the Callback URLs section.
-
Add in the callback URLs for your app, which might look something like this:
Allowed callback_URLs: "<your_custom_scheme>://kinde_callback"
Allowed logout_redirect_URLs: "<your_custom_scheme>://kinde_logoutcallback"
Note: The custom scheme can either match your appId/bundleId or be something completely new as long as it's distinct enough. Using the appId/bundleId of your app is quite common but it's not always possible if it contains illegal characters for URI schemes (like underscores) or if you already have another handler for that scheme - so just use something else.
In your main.dart file,
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:kinde_flutter_sdk/kinde_flutter_sdk.dart';
void main(){
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: ".env");
await KindeFlutterSDK.initializeSDK(
authDomain: dotenv.env['KINDE_AUTH_DOMAIN']!,
authClientId: dotenv.env['KINDE_AUTH_CLIENT_ID']!,
loginRedirectUri: dotenv.env['KINDE_LOGIN_REDIRECT_URI']!,
logoutRedirectUri: dotenv.env['KINDE_LOGOUT_REDIRECT_URI']!,
audience: dotenv.env['KINDE_AUDIENCE'], //optional
scopes: ["email","profile","offline","openid"] // optional
);
}
Note: To setup the .env file in your flutter package, check the flutter_dotenv package.
Put these variables in your .env
file. You can find these variables on your Settings > Applications > [Your app] > View details page.
-
KINDE_AUTH_DOMAIN
- your Kinde domain -
KINDE_CLIENT_ID
- your Kinde client ID -
KINDE_LOGIN_REDIRECT_URI
- your callback url to redirect to after authentication. Make sure this URL is under your Allowed callback URLs. -
KINDE_LOGOUT_REDIRECT_URI
- where you want users to be redirected to after logging out. Make sure this URL is under your Allowed logout redirect URLs. -
KINDE_AUDIENCE (optional)
- the intended recipient of an access token. To fetch this value, go to Settings > Applications > [Your app] > APIs
Below is an example of a .env
file
KINDE_AUTH_DOMAIN=https://<your_kinde_subdomain>.kinde.com
KINDE_AUTH_CLIENT_ID=<your_kinde_client_id>
KINDE_LOGIN_REDIRECT_URI=<your_custom_scheme>://kinde_callback
KINDE_LOGOUT_REDIRECT_URI=<your_custom_scheme>://kinde_logoutcallback
KINDE_AUDIENCE=<your_kinde_audience>
KINDE_AUTH_DOMAIN='https://myapp.kinde.com'
KINDE_AUTH_CLIENT_ID='clientid'
KINDE_LOGIN_REDIRECT_URI='com.kinde.myapp://kinde_callback'
KINDE_LOGOUT_REDIRECT_URI='com.kinde.myapp://kinde_logoutcallback'
KINDE_AUDIENCE='myapp.kinde.com/api'
Your user will be redirected to Kinde to authenticate. After they have logged in or registered they will be redirected back to your Flutter application.
You need to specify in Kinde which url you would like your user to be redirected to in order to authenticate your app.
On the App Keys page set Allowed callback URLs
to your deep linking
Important! This is required for your users to successfully log in to your app.
You will also need to set the url they will be redirected to upon logout. Set the Allowed logout redirect URLs
to your deep linking.
Open build.gradle
file in your app
directory of your android folder and change your scheme:
android {
defaultConfig {
manifestPlaceholders += [
'appAuthRedirectScheme': '<your_custom_scheme>'
]
}
}
Please make sure you have configuration URL scheme in Info.plist
:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>your_schema</string>
<key>CFBundleURLSchemes</key>
<array>
<string>your_custom_scheme</string>
</array>
</dict>
</array>
Run the following command to use your application
flutter run
For details on integrating this SDK into your project, head over to the Kinde docs and see the Flutter SDK doc šš¼.
The core team handles publishing.
Please refer to KindeāsĀ contributing guidelines.
By contributing to Kinde, you agree that your contributions will be licensed under its MIT License.