Google sign_in_failed 使用 firebase 身份验证的 Flutter 应用程序出错
Google sign_in_failed error in a Flutter app using firebase auth
我正在开发 Flutter 移动应用程序并在 Android 模拟器上进行测试。
我正在使用 Firebase 来处理身份验证逻辑。
我创建了一个服务
class AuthService {
Future<void> googleLogin() async {
try {
final googleUser = await GoogleSignIn().signIn();
if (googleUser == null) return;
final googleAuth = await googleUser.authentication;
final authCredential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken
);
await FirebaseAuth.instance.signInWithCredential(authCredential);
} on FirebaseAuthException catch (e) {
// handle the error
}
}
}
我按一下按钮就可以调用。我确实使用我的 Google 帐户进行身份验证,但是,终端显示此错误
PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null, null)
我在网上看到这是由于我的 firebase 项目中缺少 SHA
凭据造成的。因此,我使用项目中 android
目录中的 ./gradlew signingReport
生成了这些凭据。然后我将证书(SHA-1
和 SHA-256
添加到我的 flutter 项目中的 android 应用程序。
我再次下载了 Firebase 提供的 Google 服务文件,运行 flutter clean
和 flutter run
但是当我尝试登录。
为什么会这样?我错过了什么吗?
您必须像这样在您的 Firebase 控制台中添加支持电子邮件 ID
我正在开发 Flutter 移动应用程序并在 Android 模拟器上进行测试。
我正在使用 Firebase 来处理身份验证逻辑。
我创建了一个服务
class AuthService {
Future<void> googleLogin() async {
try {
final googleUser = await GoogleSignIn().signIn();
if (googleUser == null) return;
final googleAuth = await googleUser.authentication;
final authCredential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken
);
await FirebaseAuth.instance.signInWithCredential(authCredential);
} on FirebaseAuthException catch (e) {
// handle the error
}
}
}
我按一下按钮就可以调用。我确实使用我的 Google 帐户进行身份验证,但是,终端显示此错误
PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null, null)
我在网上看到这是由于我的 firebase 项目中缺少 SHA
凭据造成的。因此,我使用项目中 android
目录中的 ./gradlew signingReport
生成了这些凭据。然后我将证书(SHA-1
和 SHA-256
添加到我的 flutter 项目中的 android 应用程序。
我再次下载了 Firebase 提供的 Google 服务文件,运行 flutter clean
和 flutter run
但是当我尝试登录。
为什么会这样?我错过了什么吗?
您必须像这样在您的 Firebase 控制台中添加支持电子邮件 ID