3
votes

I'm working on implementing an iOS app that will be pulling content from a Google Drive document. This document would be the same for every client and completely separated from the users Google accounts. I followed the tutorials and watched the videos about how to use the SDK for Xcode projects, I also set up a Google drive app on the API console and created its service account. My problem here is how, on the client slide, to skip the user authentication step to prevent accessing their own Google account and simply connect to the app service account.

2
I am facing same issue. If you found the solution please help me to figure out.. stackoverflow.com/questions/23268608/…Bulla

2 Answers

0
votes

Even though the user is accessing their own data, your app is obtaining access to it in order to provide the user with a service or function. This makes it necessary for Google to require and obtain user consent for data sharing.

2
votes

Using the SDK with service accounts is possible in Java (Android) but not iOS. I don't know why and I hope this will change in future.

For now the only way to login programmatically to your application google account that will act as a service account is hacky. You need to log once on your app and save the authentication token retrieved from the API. Then you can reuse it like this:

_driveService = [[GTLServiceDrive alloc] init];

GTMOAuth2Authentication *auth = [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName clientID:kClientID clientSecret:kClientSecret];
[auth setKeysForPersistenceResponseString:kDriveAPIToken];
_driveService.authorizer = auth;

Google says the token won't change unless the max number of simultaneous valid tokens is reached, and then tokens are cleared by FIFO (oldest valid token is invalidated).