gpt4 book ai didi

firebase - Flutter: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

转载 作者:行者123 更新时间:2023-12-03 02:45:45 31 4
gpt4 key购买 nike

我有一个 Flutter 应用程序,我试图允许用户登录他们的 Gmail,因为我希望能够列出他们的电子邮件。当我按下我的 LoginButton ,我收到 Gmail 登录提示,我输入了我的凭据,但随后它返回到带有 LoginButton 的屏幕。我面临错误:
Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
我尝试过的:

  • 已添加 google-services.json到/android/app 并添加 GoogleService-Info.plist到 ios/运行者。
  • 为 Firebase 身份验证启用 Gmail。
  • 将我的调试 SHA1 和 SHA256 添加到我的 firebase 身份验证中。
  • 填写 OAuth 同意书(我在其他所有事情之后都这样做了。我不知道这是否会影响它。)

  • 有任何想法吗?谢谢!

    这是我的代码:
    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,
    );
    FirebaseUser user = (await _auth.signInWithCredential(credential)).user;

    updateUserData(user);
    print("signed in " + user.displayName);

    loading.add(false);
    return user;
    }

    void updateUserData(FirebaseUser user) async {
    DocumentReference ref = _db.collection('user').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();
    Launching lib\main.dart on Android SDK built for x86 in debug mode...
    Initializing gradle...
    Resolving dependencies...
    Running Gradle task 'assembleDebug'...
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
    Built build\app\outputs\apk\debug\app-debug.apk.
    Installing build\app\outputs\apk\app.apk...
    I/FA ( 4974): Tag Manager is not found and thus will not be used
    W/d.memail.memai( 4974): Accessing hidden method Landroid/view/accessibility/AccessibilityNodeInfo;->getSourceNodeId()J (light greylist, reflection)
    W/d.memail.memai( 4974): Accessing hidden method Landroid/view/accessibility/AccessibilityRecord;->getSourceNodeId()J (light greylist, reflection)
    W/d.memail.memai( 4974): Accessing hidden field Landroid/view/accessibility/AccessibilityNodeInfo;->mChildNodeIds:Landroid/util/LongArray; (light greylist, reflection)
    W/d.memail.memai( 4974): Accessing hidden method Landroid/util/LongArray;->get(I)J (light greylist, reflection)
    Syncing files to device Android SDK built for x86...
    I/OpenGLRenderer( 4974): Initialized EGL, version 1.4
    D/OpenGLRenderer( 4974): Swap behavior 1
    D/ ( 4974): HostConnection::get() New Host Connection established 0xd831cb40, tid 5016
    D/EGL_emulation( 4974): eglCreateContext: 0xec485d80: maj 2 min 0 rcv 2
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485d80: ver 2 0 (tinfo 0xec483d80)
    D/ ( 4974): HostConnection::get() New Host Connection established 0xd3f22780, tid 5005
    D/EGL_emulation( 4974): eglCreateContext: 0xec485a80: maj 2 min 0 rcv 2
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485a80: ver 2 0 (tinfo 0xec483c50)
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485d80: ver 2 0 (tinfo 0xec483d80)
    I/d.memail.memai( 4974): Background concurrent copying GC freed 35614(5MB) AllocSpace objects, 27(1068KB) LOS objects, 50% free, 1856KB/3MB, paused 498us total 214.123ms
    I/OpenGLRenderer( 4974): Davey! duration=719ms; Flags=1, IntendedVsync=65710145267, Vsync=66060145253, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=66062704600, AnimationStart=66062759800, PerformTraversalsStart=66062789600, DrawStart=66070699600, SyncQueued=66071765200, SyncStart=66073102800, IssueDrawCommandsStart=66074268300, SwapBuffers=66323835100, FrameCompleted=66431085200, DequeueBufferDuration=26966000, QueueBufferDuration=372000,
    E/EnhancedIntentService( 4974): binding to the service failed
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485a80: ver 2 0 (tinfo 0xec483c50)
    W/ActivityThread( 4974): handleWindowVisibility: no activity for token android.os.BinderProxy@b021561
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485d80: ver 2 0 (tinfo 0xec483d80)
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485d80: ver 2 0 (tinfo 0xec483d80)
    D/EGL_emulation( 4974): eglCreateContext: 0xec485b40: maj 2 min 0 rcv 2
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485b40: ver 2 0 (tinfo 0xec483c50)
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485b40: ver 2 0 (tinfo 0xec483c50)
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485d80: ver 2 0 (tinfo 0xec483d80)
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485d80: ver 2 0 (tinfo 0xec483d80)
    D/EGL_emulation( 4974): eglMakeCurrent: 0xec485d80: ver 2 0 (tinfo 0xec483d80)
    E/flutter ( 4974): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
    E/flutter ( 4974): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
    E/flutter ( 4974): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
    E/flutter ( 4974): <asynchronous suspension>
    E/flutter ( 4974): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:344:48)
    E/flutter ( 4974): <asynchronous suspension>
    E/flutter ( 4974): #3 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:218:23)
    E/flutter ( 4974): <asynchronous suspension>
    E/flutter ( 4974): #4 GoogleSignIn._addMethodCall (package:google_sign_in/google_sign_in.dart:257:20)
    E/flutter ( 4974): #5 GoogleSignIn.signIn (package:google_sign_in/google_sign_in.dart:324:48)
    E/flutter ( 4974): #6 AuthService.googleSignIn (package:memail/auth.dart:33:58)
    E/flutter ( 4974): <asynchronous suspension>
    E/flutter ( 4974): #7 LoginButton.build.<anonymous closure>.<anonymous closure> (package:memail/main.dart:86:46)
    E/flutter ( 4974): #8 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:635:14)
    E/flutter ( 4974): #9 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:711:32)
    E/flutter ( 4974): #10 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
    E/flutter ( 4974): #11 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
    E/flutter ( 4974): #12 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:275:7)
    E/flutter ( 4974): #13 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:455:9)
    E/flutter ( 4974): #14 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:75:13)
    E/flutter ( 4974): #15 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:102:11)
    E/flutter ( 4974): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
    E/flutter ( 4974): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
    E/flutter ( 4974): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
    E/flutter ( 4974): #19 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
    E/flutter ( 4974): #20 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
    E/flutter ( 4974): #21 _rootRunUnary (dart:async/zone.dart:1136:13)
    E/flutter ( 4974): #22 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
    E/flutter ( 4974): #23 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
    E/flutter ( 4974): #24 _invoke1 (dart:ui/hooks.dart:250:10)
    E/flutter ( 4974): #25 _dispatchPointerDataPacket (dart:ui/hooks.dart:159:5)
    E/flutter ( 4974):

    最佳答案

    我也遇到了这个问题..就我而言,我尝试实现 GoogleSignIn在我已经处于生产级别的应用程序之一中..

    当我尝试这样做时..我也遇到了同样的错误.. APIException: 10 .. 看起来你的也是一样的情况..

    我尝试了很多次..但是,最后,我最终妥协并决定不包括 GoogleSignIn在我的应用程序中..

    但是,再次..我解决了它..通过添加 2 SHA1 FireBase Project 的 key ..一个 debug mode和其他 release mode ..

    如果我只放调试 SHA1关键..它在 release 中不起作用模式但在 debug 中工作正常模式,如果我只放 release SHA1 key ..它在 debug 中不起作用模式但在 release 中工作正常模式 。

    不知道为什么会发生......但它正在发生......不知何故它工作正常......

    好的...现在...什么是 debugrelease关键..它们不一样..我怎么得到它们..?

    这里是..

    转到您的项目 Command Prompt .. 然后 cd android然后输入..

    gradlew signingReport

    它会给 SHA1 key ..
    debug keystore生成了一个 key 另一个由 release keystore ..

    将它们都添加到项目中......它可以工作(希望如此)......就像它对我一样......

    希望能帮助到你..

    注意:我正在使用 Windows ..不确定在 Mac 上生成 key 是否是相同的过程还有..

    关于firebase - Flutter: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58043670/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com