登录时出现钥匙串错误

Posted

技术标签:

【中文标题】登录时出现钥匙串错误【英文标题】:I'm getting keychain error when login 【发布时间】:2016-12-04 03:19:46 【问题描述】:

我已经为此苦苦挣扎了很长时间,但我没有看到隧道尽头的曙光。我正在使用 ionic 开发一个移动应用程序,并且我想添加一个 google 登录。就像我使用 firebase 一样,我已经使用 cordova-plugin-googleplus 实现了登录按钮。我一开始工作,但最近,在清理状态并重新添加 ios 平台后,它停止工作,在控制台上抛出“钥匙串错误”消息。

android 中可以正常工作;现在,我已经尝试了一切(禁用并重新启用钥匙串共享功能,清理所有环境并重建它,检查整个 GoogleService-Info.plist,检查 reversed_client_id ......我不知道我在做什么不见了)。

如果有人能帮我一把,我将不胜感激。提前致谢。

一些附加信息:

Your system information:

Cordova CLI: 6.4.0
Gulp version:  CLI version 3.9.1
Gulp local:   Local version 3.9.1
Ionic Framework Version: 1.2.1-nightly-1867
Ionic CLI Version: 2.1.4
Ionic App Lib Version: 2.1.2
ios-deploy version: 1.8.6 
ios-sim version: 5.0.11 
OS: Mac OS X Sierra
Node Version: v4.4.4
Xcode version: Xcode 8.1 Build version 8B62 

已安装插件:

cordova-plugin-calendar 4.5.5 "Calendar"
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-device 1.1.3 "Device"
cordova-plugin-dialogs 1.3.0 "Notification"
cordova-plugin-fcm 1.1.5 "FCMPlugin"
cordova-plugin-googleplus 5.1.1 "Google SignIn"
cordova-plugin-inappbrowser 1.5.0 "InAppBrowser"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-transport-security 0.1.2 "App Transport Security"
cordova-plugin-whitelist 1.3.0 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

config.xml 文件(部分):

  <plugin name="cordova-plugin-googleplus" spec="~5.1.1">
    <variable name="REVERSED_CLIENT_ID" value="XXXX-THIS_HAS_THE_CORRECT_ID-XXXXX"/>
  </plugin>

控制台上的错误信息:

keychain error

来自模拟器的 system.log 的一些错误消息:

securityd[16035]: found no keychain client entitlements. task=Xxxxx App[17178]/1#0 LF=0 procid=com.xxxx.xxxx cs_flags=0x22000201

控制器中的登录功能:

  $scope.loginGoogle = function()
    $ionicLoading.show();
    LogService.log(TAG, 'webClientId : ' + 'XXXXX');
    var clienInfo = ;

    if(ionic.Platform.isAndroid())
    
      clienInfo.webClientId = 'XXXXXXX';
    

    window.plugins.googleplus.login(
      clienInfo,
      function (obj) 
        // alert(JSON.stringify(obj));

        LogService.log(TAG, 'googleplus.login result : ' + JSON.stringify(obj));
        LogService.log(TAG, 'obj.idToken : ' + obj.idToken);
        // obj.email          // 'eddyverbruggen@gmail.com'
        // obj.userId         // user id
        // obj.displayName    // 'Eddy Verbruggen'
        // obj.familyName     // 'Verbruggen'
        // obj.givenName      // 'Eddy'
        // obj.imageUrl       // 'http://link-to-my-profilepic.google.com'
        // obj.idToken        // idToken that can be exchanged to verify user identity.
        // obj.serverAuthCode // Auth code that can be exchanged for an access token and refresh token for offline access
        var token = obj.idToken;
        var userData = 
          displayName : obj.displayName,
          avatar : obj.imageUrl,
          currentSessionOn : 'google'
        ;
        return AuthService.loginGoogle(token, userData).then(function (result) 
            $rootScope.$broadcast(AUTH_EVENTS.loginSuccess);
            $ionicLoading.hide();
            $state.go('app.tabs.events');
        ).catch(function(error)
            $ionicLoading.hide();
            $scope.message = error.message;
            $timeout(function() 
              $scope.message = null;
            , 3000);
            $rootScope.$broadcast(AUTH_EVENTS.loginFailed);     
        );
      ,
      function (msg) 
        LogService.logError(TAG, 'plugins.googleplus.login error: ' + msg);
        $ionicLoading.hide();
      );
  ;

【问题讨论】:

您的问题解决了吗?我面临同样的问题:/ 从 Xcode 启动项目似乎可以解决问题。使用 Ionic CLI 时问题仍然存在。 【参考方案1】:

从 Xcode 启动项目似乎可以解决问题。使用 Ionic CLI 时问题仍然存在。

Issue reported in github

【讨论】:

我似乎遇到了与上述相反的问题。当我从 ionic serve 启动我的项目时,它工作正常(但是我没有使用 Cordova 插件,而是使用 AngularFire2)。但是当我在 Xcode 中启动项目时,我得到了钥匙串错误

以上是关于登录时出现钥匙串错误的主要内容,如果未能解决你的问题,请参考以下文章

NSInternalInconsistencyException:无法更新钥匙串项

IOS 生产发布错误:- 错误 - 证书与配置文件不匹配:默认钥匙串没有身份匹配

想使用登录钥匙串卡死

将钥匙添加到钥匙链项目

苹果密码钥匙串在哪里

MacBook钥匙串怎么关闭