3

I have not been able to find any code examples of accessing the Google Drive API with Objective-C. Does anyone know where to find some? I have the Google Client libraries incorporated into my project, but I don't know how to start with the code.

I am particularly interested in how the authentication works since redirecting to authorization url and then back to the app like you do for web apps doesn't seem like it would work for a native iOS app.

Thanks! Chris

Shay Erlichmen
  • 31,691
  • 7
  • 68
  • 87
user1501783
  • 533
  • 2
  • 9
  • 20
  • You can find examples here: https://github.com/google/google-api-objectivec-client. Be sure to clone repository with dependency projects (use `git --recursive`) – kisileno Apr 04 '16 at 02:33

1 Answers1

2

Support for Objective C is only in alpha stage apparently.

You can find a sample drive application on google code there: http://code.google.com/p/google-api-objectivec-client/source/browse/trunk/Examples/DriveSample/

For authentication you use GTMOAuth2Authentication with an OAuth token, typically stored in the keychain:

// 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];
Julien Lebot
  • 3,092
  • 20
  • 32