Posts

Showing posts from March, 2013

Upload files to application drive account via Picker API

Google Picker API enables to pick files from Google Drive account or upload files to Google Drive account. With few lines of javascript code one can create sofisticated file upload UI. How to include Google Picker <script src="http://www.google.com/jsapi></script> google.setOnLoadCallback(createPicker); google.load('picker', '1'); /** Create picker object. */ function createPicker() { // Use DocsUploadView to upload documents to Google Drive. var uploadView = new google.picker.DocsUploadView(); var picker = new google.picker.PickerBuilder(). addView(uploadView). setAppId("xxxxxxxxxxxxxxxxxx"). // setOAuthToken(ACCESS_TOKEN). setCallback(pickerCallback). build(); picker.setVisible(true); } /** A simple callback implementation. */ function pickerCallback(data) { if (data.action == google.picker.Action.PICKED) { var fileId = data.docs[0].id; alert('The user selecte

Access application Google Drive account from javascript without client side authorization dialog

Use case We want to create a regular Google Drive account owned by an application. The application enables users to upload or view files within that account. Since Google Drive API provides javascript library the goal is to use javascript for all the logic (upload and view files) with minimum engagement of server side processing. For the purpose of creating an application owned account Google provides two options: SERVICE ACCOUNT Application is authorized by .pk12 certificate; the drawback is that only the application can see documents it created - documents cannot be viewed for example through Google Drive UI. REGULAR GOOGLE ACCOUNT used by the application only This option is our choice because we want to access stored files using Google Drive UI too. More information about the two options is available in Google Drive SDK documentation . To access a Google account using Google API we have to ensure correct handling of authentication and authorization procedures - Google A