3

我找不到任何使用 Objective-C 访问 Google Drive API 的代码示例。有谁知道在哪里可以找到一些?我已将 Google 客户端库合并到我的项目中,但我不知道如何从代码开始。

我对身份验证的工作方式特别感兴趣,因为重定向到授权 url,然后像您对 Web 应用程序所做的那样返回到应用程序,这似乎不适用于本机 iOS 应用程序。

谢谢!克里斯

4

1 回答 1

2

对 Objective C 的支持显然只处于 alpha 阶段

您可以在 google 代码上找到示例驱动应用程序:http ://code.google.com/p/google-api-objectivec-client/source/browse/trunk/Examples/DriveSample/

对于身份验证,您使用 GTMOAuth2Authentication 和 OAuth 令牌,通常存储在钥匙串中:

// Load the OAuth token from the keychain, if it was previously saved
NSString *clientID = [clientIDField_ stringValue];
NSString *clientSecret = [clientSecretField_ stringValue];

GTMOAuth2Authentication *auth;
auth = [GTMOAuth2WindowController authForGoogleFromKeychainForName:kKeychainItemName
                                                          clientID:clientID
                                                      clientSecret:clientSecret];
于 2012-07-06T12:57:39.647 回答