“访问钥匙串时发生错误". [英] "An error occurred when accessing the keychain"

查看:42
本文介绍了“访问钥匙串时发生错误".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Flutter使用Firebase Auth插件,以便在我的应用中通过Google登录,并且可以正常运行在iOS和Android上运行.

当我尝试在iOS"Share Extension"中使用Firebase Auth时,我的问题开始了.我是iOS新手,所以我对Swift和Xcode并不是很熟悉,但是据我了解,我应该

启用钥匙串共享"后,尝试使用Firebase Auth登录时出现以下错误:

 未处理的异常:PlatformException(ERROR_KEYCHAIN_ERROR,访问钥匙串时发生错误.@c NSError.userInfo词典中的@c NSLocalizedFailureReasonErrorKey字段将包含有关遇到的错误的更多信息,null)#0 StandardMethodCodec.decodeEnvelope(软件包:flutter/src/services/message_codecs.dart:569:7)#1 MethodChannel.invokeMethod(软件包:flutter/src/services/platform_channel.dart:321:33)<异步暂停>#2 MethodChannel.invokeMapMethod(package:flutter/src/services/platform_channel.dart:349:48)#3 MethodChannelFirebaseAuth.signInWithCredential(package:firebase_auth_platform_interface/src/method_channel_firebase_auth.dart:161:23)#4 FirebaseAuth.signInWithCredential(软件包:firebase_auth/src/firebase_auth.dart:208:10)#5 signInWithGoogle(package:matkonit/google_sign_in.dart:17:45)<异步暂停>#6 LoginPageState.signInButton.<匿名闭包>.<匿名clo<…> 

这是我打印 NSLocalizedFailureReasonErrorKey 时得到的:

  SecItemCopyMatching(-34018) 

该如何解决?


我注意到重新启动模拟器可以使登录正常工作,但只是有时...我不知道为什么.

解决方案

我没有在我的App ID之前添加团队ID前缀,所以它不起作用.为此,您需要具有Apple Developer Account和Team ID,

  Auth.auth().useUserAccessGroup("XK ********.com.matkonit.SharedItems") 

I use Firebase Auth plugin for Flutter in order to sign in with Google in my app, and it works fine in both iOS and Android.

My problem starts when I try to use Firebase Auth in my iOS "Share Extension". I am new to iOS so I am not really familiar with Swift and Xcode, but as far as I understand I should enable cross-app authentication with shared iOS Keychain in order to authenticate the user in my shared extension.

I have 2 targets in my project, the "Runner" and the "Share Extension" so I have enabled the Keychain Sharing for both of them:

When the Keychain Sharing is enabled, I get the following error when I try to sign in using Firebase Auth:

Unhandled Exception: PlatformException(ERROR_KEYCHAIN_ERROR, An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
<asynchronous suspension>
#2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349:48)
#3      MethodChannelFirebaseAuth.signInWithCredential (package:firebase_auth_platform_interface/src/method_channel_firebase_auth.dart:161:23)
#4      FirebaseAuth.signInWithCredential (package:firebase_auth/src/firebase_auth.dart:208:10)
#5      signInWithGoogle (package:matkonit/google_sign_in.dart:17:45)
<asynchronous suspension>
#6      LoginPageState.signInButton.<anonymous closure>.<anonymous clo<…>

This is what I get when I print the NSLocalizedFailureReasonErrorKey:

SecItemCopyMatching (-34018)

What can I do in order to fix this?


Edit: I have noticed that restarting the simulator makes the sign in work, but only sometimes... I couldn't figure out why.

解决方案

I didn't add the Team ID prefix before my App ID, so it didn't work. You need to have an Apple Developer Account and a Team ID in order to do this, like this:

Auth.auth().useUserAccessGroup("XK********.com.matkonit.SharedItems")

这篇关于“访问钥匙串时发生错误".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆