web-dev-qa-db-ja.com

PlatformException(PlatformException(sign_in_failed、com.google.Android.gms.common.api.ApiException:12500:、null))

クラッシュする行:

GoogleSignInAccount googleUser = await _googleSignIn.signIn();

何を試しましたか:

  1. このコマンドkeytool -list -v \ -alias androiddebugkey -keystore ~/.Android/debug.keystoreでSH1キーを生成しました
  2. SH1暗号化をconsole.firebase.google.comに追加する
  3. Google-service.jsonを再ダウンロードする
  4. debug.keystore.AndroidからMyProject/Androidにコピーしています
  5. デバッグで実行してリリース
  6. これらの行をAndroid/build.gradleに追加します。

    • classpath 'com.Android.tools.build:gradle:3.2.1'
    • classpath 'com.google.gms:google-services:4.2.0'
  7. Android/app/build.gradleに次の行を追加します:

    • implementation 'com.google.firebase:firebase-core:16.0.9'underdependencies
    • apply plugin: 'com.google.gms.google-services'on the end of the file。
  8. これらの行を含むプロジェクトフォルダーの下にrelease-signing.propertiesという名前のファイルを作成します。
    • storeFile = debug.keystore
    • keyAlias = androiddebugkey
    • storePassword = Android
    • keyPassword = Android

また、すべてのStackOverflow質問を検索しましたが、この質問で見つけることができましたが、どれも役に立ちませんでした。

私のpubspec.yaml:

firebase_core: ^0.4.0+1
firebase_analytics: ^3.0.1

cloud_firestore: ^0.11.0+2

firebase_auth: ^0.11.1
google_sign_in: ^4.0.1+3

rxdart: ^0.22.0

認証クラス:

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 user) {
      if (user != null) {
        return _db
            .collection('user')
            .document(user.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;
    // FirebaseUser user = await _auth.signInWithGoogle(
        // accessToken: googleAuth.accessToken, idToken: googleAuth.idToken);
    final AuthCredential credential = GoogleAuthProvider.getCredential(
      accessToken: googleAuth.accessToken,
      idToken: googleAuth.idToken,
    );
    FirebaseUser user = await _auth.signInWithCredential(credential);
    updateUserData(user);
    print("Sign in" + user.displayName);

    loading.add(false);

    return user;
  }
}

メインクラス:

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  AuthService authService = AuthService();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blueGrey,
      ),
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              MaterialButton(
                child: Text("Log in with Google"),
                color: Colors.blueGrey,
                textColor: Colors.deepOrange,
                onPressed: () => authService.googleSignIn(),
              ),
              MaterialButton(
                child: Text("LogOut"),
                color: Colors.redAccent,
                textColor: Colors.purple,
                onPressed: () => authService.signOut(),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

誰かが私を正しい方向に向けることができれば、私はとても感謝しています。

ここに私がすでに試したいくつかのstackoverflowリンクがあります:

  1. フラッターアプリのリリース後、Googleログインは機能しません
  2. Flutterおよびgoogle_sign_inプラグイン:PlatformException(sign_in_failed、com.google.Android.gms.common.api.ApiException:10:、null)
  3. Googleサインインエラー125

どれもうまくいかなかったので、どう思いますか、どうすれば修正できますか。

4
Mircea

私はインターネットから検索できるほとんどすべての回答も試しました。そのため、iOS側を試すことにしましたが、それでもエラー「403制限付きクライアント」が表示されます。その後、サーバー側の問題であると判断しました。最後に、サポートを設定するのを忘れてe Google Developers Consoleのメールアドレス> APIとサービス>証明書>ユーザーの同意画面 link そして、このオプションはFirebaseプロジェクトの設定でも同じです。設定後、すべてが機能するはずです。

1
flutroid

ドキュメントに記載されているすべての手順を実行した後、私でも同じ問題に直面していました。私のために働いたことの1つは、Firebaseコンソールの設定ページにサポートメールを追加することです

1
Farmaan Elahi

GoogleアカウントのAPI&Servciesページに移動し、以下に示すように左上隅で目的のプロジェクトを選択してください

enter image description here

上記で入力したサポートメールIDがあることを確認してください

以下のすべてのフィールドには値が必要です

enter image description here

ログインしてみてください、うまくいきます!

1

私は同じ問題に出くわしました、私のための問題を解決したのは、SHA-1にSHA-256フィンガープリントを追加することでした

ここで述べたように-> Flutterおよびgoogle_sign_inプラグイン:PlatformException(sign_in_failed、com.google.Android.gms.common.api.ApiException:10:、null)

それもあなたのために働くことを願っています!

0
M. Werder