I am writing a Chrome App and I want to use the Google Drive API to let my users read/write files to their own Google Drive.
I have found info suggesting that the only way to go through the OAuth flows from a Chrome App is to use a webview (see this previous StackOverflow question Google Drive Realtime API in a Chrome Packaged App).
This restriction makes sense to me because to go through an OAuth flow you have to load external content, and keeping this isolated from the privileged Chrome App code sounds important from a security perspective.
But once you have the OAuth access token, it seems like the JavaScript from the Chrome App should be able to make requests to the Google Drive API directly. This isn't loading any content (ie. HTML or JS) into the browser, it's just calling a remote API to read/write data.
But it appears that the only supported way to use the Google JavaScript API is to load it remotely, using code like this:
<script src="https://apis.google.com/js/client.js"></script>
This won't work because the Chrome App isn't allowed to load remote content.
And my idea of just downloading that client.js
and dropping it in my local Chrome App directory doesn't work, because client.js
seems to assume that it can continue downloading/executing more JavaScript as necessary.
So basically, from what I can tell, the Google JavaScript API appears to be hostile to being downloaded ahead-of-time and run from local files only. Does that sound accurate? If so, the only way for the app to get remote data from the API is to pass messages between the webview and the main app, which sounds like a huge pain.
Any solution to this? Or do I have to tunnel all data to/from the API through a webview? :(