I have implemented remote connection to Google Drive in my iOS app using the Google Drive SDK.
I can successfully access file/folder lists and metadata using GTLServiceDrive
class and download content using the GTMHTTPFetcher
class.
When I download content using the GTMHTTPFetcher
class, I use the GTLServiceDrive
key downloadUrl
, and I use a line of code to authorise the download - per the second line of code following...
GTMHTTPFetcher *fetcher = [googleDriveService.fetcherService fetcherWithURLString: << downloadUrl >>];
[fetcher setAuthorizer:googleDriveService.authorizer];
where googleDriveService
is an instance of GTLServiceDrive
class.
For certain files located on Google Drive, I have the user of my app select from two options - whether they want to download a copy to save on device, or just maintain a reference using the GTLServiceDrive
key webContentLink
and access content on demand (without downloading and saving to Documents or Caches).
For this second option I would like my app to present the file in a UIWebView
.
It is almost working with the following code...
...other code to prepare UIWebView...
NSURLRequest *request = [NSURLRequest requestWithURL: << webContentLink >>];
[webView loadRequest:request];
The web view loads, however presents the OAuth login page, I guess because the loadRequest: method is asking for access to a private file without authorisation.
I note...
- that I have already set an OAuth keychain item during an initial connection (setup process) to retrieve folder & file lists & metadata.
- that once I log in for the second time using this second OAuth view controller, that login appears to persist (not being required again) including after device shutdown and reboot.
Perhaps a second keychain item is automatically added?
Is there some method I can use, similar to GTMHTTPFetcher
class with its authorise property, to allow me to present the Google Drive file in a UIWebView
but without asking the user to complete a second login, albeit that they are required to do this second login only once?