Я попробовал реализовать вход в Microsoft в приложении Flutter с Firebase. После входа в систему я получаю следующую ошибку: Конечная точка принимает только запросы POST. Получен запрос GET., но пользователь неправильно перенаправлен в мое приложение. При повторном открытии приложения я успешно вошел в систему.
Я использовал код:
main.file
import 'package:email_validator/email_validator.dart';
import 'package:firebase_auth/firebase_auth.dart' as fire;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../../general/functions.dart';
import '../../general/functionsFirebaseWrite.dart';
import '../../main.dart';
import '../../theme/colors.dart';
//import 'dart:io' show Platform;
class Login extends StatefulWidget {
const Login({super.key});
@override
State createState() => LoginState();
}
class LoginState extends State {
late String? errorPassword = null;
late String? errorEmail = null;
late bool passwordVisible;
final emailController = TextEditingController();
final passwordController = TextEditingController();
@override
void dispose() {
emailController.dispose();
passwordController.dispose();
super.dispose();
}
@override
void initState() {
passwordVisible = false;
}
Future onLoginClicked() async {
setState(() {
errorEmail = null;
errorPassword = null;
});
showLoaderDialog(context);
try {
await fire.FirebaseAuth.instance.signInWithEmailAndPassword(
email: emailController.text.trim(),
password: passwordController.text.trim(),
); //LOGIC THAT HANDLES THE LOGIN IS IN THE STREAM BUILDER OF THE main.dart WIDGET TREE
navigatorKey.currentState!.popUntil((route) => route.isFirst);
} on fire.FirebaseAuthException catch (error) {
navigatorKey.currentState!.popUntil((route) => route.isFirst);
giveBackErrorMessage(error.message!);
}
}
Future onMicrosoftLoginClicked() async {
final microsoftProvider = fire.MicrosoftAuthProvider();
microsoftProvider.setCustomParameters({'prompt': 'select_account'});
microsoftProvider.addScope('User.Read'); // Request mandatory permission
showLoaderDialog(context);
try {
if (kIsWeb) {
// Web platform
final credential =
await fire.FirebaseAuth.instance.signInWithPopup(microsoftProvider);
Navigator.of(context, rootNavigator: true).pop();
return credential;
} else {
// Mobile platform
Navigator.of(context, rootNavigator: true).pop();
final credential = await fire.FirebaseAuth.instance
.signInWithProvider(microsoftProvider);
return credential;
}
} on fire.FirebaseAuthException catch (error) {
Navigator.of(context, rootNavigator: true).pop();
giveBackErrorMessage(error.message!);
return null;
} catch (error) {
Navigator.of(context, rootNavigator: true).pop();
giveBackErrorMessage('An unexpected error occurred: ${error.toString()}');
return null;
}
}
giveBackErrorMessage(String error) {
String errorMess;
if (error ==
"The password is invalid or the user does not have a password.") {
errorMess =
"Passwort ist falsch. Oder das Konto ist mit Microsoft verknüpft.";
setState(() {
errorPassword = errorMess;
});
} else if (error ==
"There is no user record corresponding to this identifier. "
"The user may have been deleted.") {
errorMess = "Email ist nicht bekannt.";
setState(() {
errorEmail = errorMess;
});
} else if (error ==
"Access to this account has been temporarily disabled due "
"to many failed login attempts. You can immediately restore it by resetting "
"your password or you can try again later.") {
//Utils.showSnackbar(error.message);
errorMess = "Account temporär gesperrt. Später erneut versuchen";
setState(() {
errorEmail = errorMess;
});
} else if (error ==
"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.") {
errorMess =
"Diese Email ist mit einem FirmParking-Konto verknüpft. Bitte loggen sie sich hier ein.";
setState(() {
errorEmail = errorMess;
});
} else {
print(error);
errorMess = "Fehler beim anmelden. Erneut versuchen.";
setState(() {
errorEmail = errorMess;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 60),
child: Wrap(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 150),
Image.asset(
'assets/logo_round.png', // Replace with your own image
width: 180,
),
const SizedBox(height: 80),
SizedBox(
width: 250,
child: TextFormField(
textAlign: TextAlign.center,
controller: emailController,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (email) {
email != null && !EmailValidator.validate(email)
? "Email falsch formatiert"
: null;
return null;
},
decoration: InputDecoration(
labelText: 'Email',
errorText: errorEmail,
errorMaxLines: 3,
filled: true,
fillColor: Colors.grey[200],
labelStyle: const TextStyle(
color: CustomColor.darkBlueColor,
fontSize: 14,
fontWeight: FontWeight.normal,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide.none,
),
contentPadding: const EdgeInsets.symmetric(
vertical: 5,
horizontal: 20,
),
),
),
),
const SizedBox(height: 20),
SizedBox(
width: 250,
child: TextFormField(
textAlign: TextAlign.center,
controller: passwordController,
obscureText: !passwordVisible,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (pwd) {
pwd != null && pwd.length < 6
? "Min. 6 Zeichen eingeben"
: null;
return null;
},
decoration: InputDecoration(
suffixIcon: IconButton(
icon: Icon(
passwordVisible
? Icons.visibility
: Icons.visibility_off,
color: CustomColor.blueColor,
size: 15,
),
onPressed: () {
setState(() {
passwordVisible = !passwordVisible;
});
},
),
labelStyle: const TextStyle(
color: CustomColor.darkBlueColor,
fontSize: 14,
fontWeight: FontWeight.normal,
),
errorText: errorPassword,
errorMaxLines: 2,
labelText: 'Passwort',
filled: true,
fillColor: Colors.grey[200],
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide.none,
),
contentPadding: const EdgeInsets.symmetric(
vertical: 5,
horizontal: 20,
),
),
),
),
const SizedBox(
height: 10,
),
Align(
alignment: Alignment.center,
child: GestureDetector(
onTap: () {
if (EmailValidator.validate(
emailController.text.trim())) {
onForgetPasswordClicked(
context, emailController.text.trim());
} else {
setState(() {
errorEmail = "Geben sie eine valide Email ein";
});
}
},
child: const Text(
'Passwort vergessen?',
style: TextStyle(
color: CustomColor.darkBlueColor,
fontWeight: FontWeight.normal,
),
),
),
),
const SizedBox(height: 40),
SizedBox(
width: 250,
child: ElevatedButton(
onPressed: () => onLoginClicked(),
style: ElevatedButton.styleFrom(
backgroundColor: CustomColor.darkBlueColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 40,
),
),
child: Container(
width: double.infinity,
alignment: Alignment.center,
child: const Text(
'LOGIN',
style: TextStyle(
fontSize: 14,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
),
),
const SizedBox(height: 40),
Visibility(
visible: true,
child: TextButton(
onPressed: () {
onMicrosoftLoginClicked();
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
'assets/microsoft.png', // Replace with Microsoft logo
width: 20,
height: 20,
),
const SizedBox(width: 10),
const Text(
'LOGIN MIT MICROSOFT',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
],
),
],
),
),
);
}
}
Я настроил свой проект в соответствии с этой документацией:
Аутентификация с помощью Microsoft на Android
В то время как IOS и WEB работает хорошо, я получаю следующую ошибку при входе в систему на устройстве Android. При возвращении в приложение я успешно вхожу в систему. Единственное решение этой проблемы, которое я нашел, — это отключение параметра Блокировать сторонние файлы cookie и данные сайта. Я не хочу, чтобы всем моим пользователям приходилось это делать. Каким будет это взаимодействие с пользователем?
При добавлении следующего кода в мой манифест:
Я попробовал реализовать вход в Microsoft в приложении Flutter с Firebase. После входа в систему я получаю следующую ошибку: [b]Конечная точка принимает только запросы POST. Получен запрос GET.[/b], но пользователь неправильно перенаправлен в мое приложение. При повторном открытии приложения я успешно вошел в систему. Я использовал код: main.file [code]import 'package:aad_oauth/model/config.dart'; import 'package:firmparking/pages/General/InitialiseScreen.dart'; import 'package:firmparking/pages/General/RequestWaiting.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:firmparking/pages/General/HomePage.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:intl/date_symbol_data_local.dart'; import 'classes/Admin.dart'; import 'classes/UserRequest.dart'; import 'general/functions.dart'; import 'general/functionsFirebaseRead.dart'; import 'general/functionsFirebaseWrite.dart'; import 'pages/General/Login.dart'; import 'package:platform/platform.dart';
class Login extends StatefulWidget { const Login({super.key});
@override State createState() => LoginState(); }
class LoginState extends State { late String? errorPassword = null; late String? errorEmail = null; late bool passwordVisible; final emailController = TextEditingController(); final passwordController = TextEditingController();
giveBackErrorMessage(String error) { String errorMess; if (error == "The password is invalid or the user does not have a password.") { errorMess = "Passwort ist falsch. Oder das Konto ist mit Microsoft verknüpft."; setState(() { errorPassword = errorMess; }); } else if (error == "There is no user record corresponding to this identifier. " "The user may have been deleted.") { errorMess = "Email ist nicht bekannt."; setState(() { errorEmail = errorMess; }); } else if (error == "Access to this account has been temporarily disabled due " "to many failed login attempts. You can immediately restore it by resetting " "your password or you can try again later.") { //Utils.showSnackbar(error.message); errorMess = "Account temporär gesperrt. Später erneut versuchen"; setState(() { errorEmail = errorMess; }); } else if (error == "An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.") { errorMess = "Diese Email ist mit einem FirmParking-Konto verknüpft. Bitte loggen sie sich hier ein."; setState(() { errorEmail = errorMess; }); } else { print(error); errorMess = "Fehler beim anmelden. Erneut versuchen."; setState(() { errorEmail = errorMess; }); } }
[/code] Я настроил свой проект в соответствии с этой документацией: Аутентификация с помощью Microsoft на Android В то время как IOS и WEB работает хорошо, я получаю следующую ошибку при входе в систему на устройстве Android. При возвращении в приложение я успешно вхожу в систему. Единственное решение этой проблемы, которое я нашел, — это отключение параметра [b]Блокировать сторонние файлы cookie и данные сайта[/b]. Я не хочу, чтобы всем моим пользователям приходилось это делать. Каким будет это взаимодействие с пользователем? При добавлении следующего кода в мой манифест: [code]
Я попробовал реализовать вход в Microsoft в приложении Flutter с Firebase. После входа в систему я получаю следующую ошибку: Конечная точка принимает только запросы POST. Получен запрос GET. , но пользователь неправильно перенаправлен в мое...
Я попробовал реализовать вход в Microsoft в приложении Flutter с Firebase. После входа в систему я получаю следующую ошибку: Конечная точка принимает только запросы POST. Получен запрос GET. , но пользователь неправильно перенаправлен в мое...
Я пытаюсь создать подписку на сетку событий для получения уведомлений пользователей с использованием библиотеки Microsoft Graph. Однако, создавая подписку, я столкнулся с следующей ошибкой:
«Проверка проверки подписки. Это происходит потому, что...
Эта строка кода в Java дает ошибку. Но когда я смотрел учебник, это не получило ошибки. Как я могу это исправить? Спасибо
public class Main {
public static void main(String[] args) {
Point point = new Point(x:1, y:1);
System.out.println(point);
}...