简体   繁体   English

未处理的异常:PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null)

[英]Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null)

Please read the question before sitting it to duplicate请在坐下来复制之前阅读问题

I'm trying to make google sign in feature in my app but this error keeps showing up我正在尝试在我的应用中使用谷歌登录功能,但此错误不断出现

I've done the following:我做了以下事情:

  • added support email添加了支持电子邮件
  • activated google signin in flutter console在颤振控制台中激活谷歌登录
  • generated the sha1 and signed it to firebase生成 sha1 并将其签名到 firebase
  • added the following dependencies:添加了以下依赖项:
    • firebase_core: ^0.4.0+6 firebase_core:^0.4.0+6
    • firebase_auth: ^0.11.1+8 firebase_auth: ^0.11.1+8
    • google_sign_in: ^4.0.4 google_sign_in: ^4.0.4
    • rxdart: ^0.22.0 rxdart:^0.22.0
    • cloud_firestore: ^0.12.7 cloud_firestore:^0.12.7
  • updated gradle to version 5.1.1 (latest for the time being posted)将 gradle 更新到 5.1.1 版(目前发布的最新版本)

what I already tried:我已经尝试过的:

here is the brains of the app这是应用程序的大脑

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:rxdart/rxdart.dart';

class AuthService {

  final GoogleSignIn _googleSignIn = GoogleSignIn();
  final FirebaseAuth _auth = FirebaseAuth.instance;
  final Firestore _db = Firestore.instance;

  Observable<FirebaseUser> user;
  Observable<Map<String, dynamic>> profile;
  PublishSubject loading = PublishSubject();

  AuthService() {
    user = Observable(_auth.onAuthStateChanged);

    profile = user.switchMap((FirebaseUser u) {
      if (u != null) {
        return _db
            .collection('users')
            .document(u.uid)
            .snapshots()
            .map((snap) => snap.data);
      } else {
        return Observable.just({});
      }
    });
  }

  Future<FirebaseUser> googleSignIn() async {
    loading.add(true);

    GoogleSignInAccount googleUser = await _googleSignIn.signIn();

    GoogleSignInAuthentication googleAuth = await googleUser.authentication;

    final AuthCredential credential = GoogleAuthProvider.getCredential(
      accessToken: googleAuth.accessToken,
      idToken: googleAuth.idToken,
    );

    final FirebaseUser user = await _auth.signInWithCredential(credential);
    print("signed in " + user.displayName);

    updateUserData(user);

    loading.add(false);
    print("signed in " + user.displayName);
    return user;
  }

  void updateUserData(FirebaseUser user) async {
    DocumentReference ref = _db.collection('users').document(user.uid);

    return ref.setData({
      'uid': user.uid,
      'email': user.email,
      'photoURL': user.photoUrl,
      'displayName': user.displayName,
      'lastSeen': DateTime.now()
    }, merge: true);
  }

  void signOut() {
    _auth.signOut();
  }
}

final AuthService authService = AuthService();

I found the answer here https://github.com/flutter/flutter/issues/33393#issuecomment-510395178 you don't have to add the links listed in the comment, just update the picture with anything and it will work我在这里找到了答案https://github.com/flutter/flutter/issues/33393#issuecomment-510395178您不必添加评论中列出的链接,只需用任何内容更新图片即可

the docs needs to be updated文档需要更新

For me adding scopes and hostedDomain in GoogleSignIn method works.对我来说,在 GoogleSignIn 方法中添加范围和托管域是可行的。

final GoogleSignInAccount? googleUser = await GoogleSignIn(
        scopes: ['email', 'profile'],
        hostedDomain: '',
      ).signIn();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) - PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) Flutter:Firebase:PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,null) - Flutter: Firebase: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) Unhandled Exception: PlatformException (sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) - works well in one system - Unhandled Exception: PlatformException (sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) - works well in one system Flutter:使用 google_sign_in 时出现 PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,null) - Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) when using google_sign_in PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10:, null, null) 尝试在 flutter 中使用 googleSignIn 时 - PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) When trying to use googleSignIn in flutter PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) Getting this error While Sign in with Google Play - PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) Getting this error While Sign in with Google Play 异常com.google.android.gms.common.api.ApiException:12500 - Exception com.google.android.gms.common.api.ApiException: 12500 Android Google 登录失败 com.google.android.gms.common.api.ApiException: 12500 - Android Google Sign In Failed com.google.android.gms.common.api.ApiException: 12500 Google 登录引发异常 com.google.android.gms.common.api.ApiException: 12500 - Google Sign In throws an exception com.google.android.gms.common.api.ApiException: 12500 com.google.android.gms.common.api.ApiException: 12500 - com.google.android.gms.common.api.ApiException: 12500
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM