ios - 将 AccessToken 保存到 Google Drive API 的钥匙串(keychain)

标签 ios google-drive-api google-oauth

我正在使用 Google-API-Client 和 gtm-oauth2 库。当登录成功完成时

- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
  finishedWithAuth:(GTMOAuth2Authentication *)authResult
             error:(NSError *)error {

我在 authResult.authResult 中返回了一个访问 token

但是,如果我自动或使用

查看保存到钥匙串(keychain)中的内容
[GTMOAuth2ViewControllerTouch saveParamsToKeychainForName:kGoogleKeychainItemName authentication:authResult];

我没有看到访问 token 在我检索后被保存。仅保存刷新 token

如果我立即或任何其他时间做

GTMOAuth2Authentication *auth =     
    [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kGoogleKeychainItemName
                                                          clientID:kGoogleClientID
                                                      clientSecret:kGoogleClientSecret error:&error];

我的访问 token 为零

我认为这是故意的,但我看不到任何相关文档。为什么会发生这种情况,背后的想法是什么。

最佳答案

数据未保存的原因有以下几种:

  1. 可能方法 (authForGoogleFromKeychainForName) 不受支持。

  2. 如果手机中存在指纹扫描仪,则可能在使用钥匙串(keychain)的设置中应该有其他功能 - 我们在存在指纹的手机上存在一些保存问题。

关于ios - 将 AccessToken 保存到 Google Drive API 的钥匙串(keychain),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31676896/

相关文章:

iOS - 两个应用程序目标,共享应用内购买

ios - 如何从 swift5 的 WebView 中删除 iOS 内部的滚动?

ios - 当 View Controller 以编程方式呈现时,如何知道它何时展开

python - Google Drive api - 不支持 map 导出(python)

asp.net-mvc-4 - 如何将 MVC 4 OpenId Google 登录迁移到 OAuth 2.0 或 Google+ 登录

azure - 使用 Azure DevOps 调用RestAPI

ios - 动态改变容器的高度

google-drive-api - 使用 google drive rest 递归搜索文件

google-drive-api - 在 Google Drive API v2 中查找 "full path"的文件的正确方法是什么

javascript - 如何正确使用谷歌的Javascript OAuth2.0库