Flutter Auth using Firebase Oauth and Azure AD
you need to check your flutter version to avoid any error using “flutter doctor” in Cmd windows or terminal MacOS .
then you can create your flutter application using this Cmd line “flutter create ‘your app name’ ”. if you have an existing Application Jump this step.
for firebase using this link ‘ https://firebase.google.com/ ’ to create your firebase app and connect it with flutter this video is enough for you:
Congratulations, now you have Flutter app connected with firebase app.
if you have any problem with android side you can upgrade minSdkVersion to 20.
for Azure Active Directory
1- login to your Account in Microsoft
2- go to your Azure portal from this link : https://portal.azure.com/
3- go to Azure Active Directory
we will move to firebase to finish Microsoft login and get redirect url.
Go to your firebase app and select Authentication
now return to your Azure Active Directory and create new registration
now you have a registration in Azure AD
in firebase app
Return again to your registration in Azure AD
create new secret and name it as you want and copy that secret value
now you connected between firebase, flutter and Microsoft Azure AD
now you need to setup your flutter app to authenticate follow these steps:
From pub.dev:
Install this package to your flutter app in pubspec.yamel file
add this function in your main.dart file
Future<void> performLogin(String provider, List<String> scopes,
Map<String, String> parameters) async {
try {
await FirebaseAuthOAuth().openSignInFlow(provider, scopes, parameters);
} on PlatformException catch (error) {
debugPrint("${error.code}: ${error.message}");
}
Navigator.of(context).pushNamed('/home')
/* '/home' is name of route you can add in material
routes: {
'/home': (context) => const Home(),
}
*/}
If you have an error in login the app will print it and if there is no any problem the app will move you to the home page
now using floatActionButton by changing the function to be
onPressed: () async {
await performLogin("microsoft.com", [
"email openid"
], {
'tenant': 'Add tour Tent'
});
},
if you need more details you can use this References :
Need any additional information contact me via my email : ahmadelshafee28@gmail.com
Thanks for your patience