google drive & google drive sdk

Download Google Drive & Google Drive SDK

Post on 06-May-2015




0 download

Embed Size (px)


This presentation will help you to know more about Google Drive and Google Drive SDK , so you can use the API in several Applications .


  • 1.Google Drive and the Google Drive SDK Building Drive apps Abdelhalim Lagrid Google Developer Group, Algiers 1

2. Introduction : One of Cloud googles products : lunched in 2012 ..known by Google Drive API . 3. What is Google Drive? Yea, some marketing :)2222 4. Access Anywhere Google Drive is everywhere you are -- on the web, in your home, at the office, and on the go. So wherever you are, your stuff is just...there. Ready to go, ready to share. Install it on:PC, Mac, Android, iOS 5. Store your files in a safe placeThings happen. Your phone goes for a swim. Your laptop takes an infinite snooze. No matter what happens to your devices, your files are safely stored in Google Drive. 6. Powerful searchGoogle Drive can search keywords in your files -- even the text in pictures -- to help you quickly find what you're looking for. 7. View anythingWhen a coworker shares a file with you, you may not have the supported software on your computer. With Google Drive you can open and view over 35 file types directly in the browser. 8. Access to a world of apps! Google Drive works with the apps that make you more efficient. Choose from a growing set of productivity applications, integrated right into your Drive. 9. Google Drive SDK Why integrate with Google Drive? 10. Drive SDK opportunity++ Extensive Reach Put your app in front of millions of users with billions of filesEffortless Integration Get the best of Google Drive's sharing capabilities, storage capacity and user identity management so you can focus on your app 11. Drive SDK featuresDrive Create, Read, List, Manage files through the API Search, sharing and revisionsDrive Web UI Open files and docs with your app directly from Drive 12. Integrating with Google Drive Getting Started 13. Steps for integrating your app w/ DrivePrerequisites: Create a project in the Google APIs Console Enable the Drive API Create OAuth 2.0 credentialsIntegration steps: Auth with OAuth 2.0 [& OpenID Connect] Write code for opening / saving / managing files 14. OAuth 2.0 Introduction 15. A cool tool...OAuth 2.0 Playground 16. Integrating with Google Drive Handling Authorization for Web apps 17. Authorization Using OAuth 2.0 - Redirecting users to the Grant screen Pythondecorator = OAuth2Decorator(client_id=settings.CLIENT_ID, client_secret=settings.CLIENT_SECRET, scope=settings.SCOPE, user_agent='we-cloud') class Documents(webapp.RequestHandler): @decorator.oauth_required def get(self): user = users.get_current_user() if user: service = build('drive', 'v2', http=decorator.http()) 18. Integrating with Google Drive Interacting with Drive files 19. Instantiating the Drive service ObjectPython# Here is the Drive service service = build('drive', 'v2', http=decorator.http()) 20. Creating FoldersPythonfolder = { 'title': self.request.get('project[name]'), 'mimeType': 'application/' } created_folder = service.files().insert(body=folder).execute() projectcollectionid = created_folder['id'] 21. Creating FilesPythonmimetype = 'application/' + self.request.get('doc[type]') document = { 'title': self.request.get('doc[name]'), 'mimeType': mimetype } if projectcollectionid: document['parents'] = [{'id': projectcollectionid}] created_document = service.files().insert(body=document).execute() resourceid = created_document['id'] 22. Sharing FilesPython#Share the file with other members new_permission = { 'value': email, 'type': 'user', 'role': 'writer' } service.permissions().insert(fileId=fileid, body=new_permission).execute() 23. Searching for files def retrieve_all_files(service,query): result = [] page_token = None param = {} param['q'] = "fullText contains '"+ query + "'" param['fields'] = "items(id,parents/id)" while True: try: if page_token: param['pageToken'] = page_token files = service.files().list(**param).execute() result.extend(files['items']) page_token = files.get('nextPageToken') if not page_token: break except errors.HttpError, error:Python 24. Integrating with Google Drive Adding the Drive Web-UI Integration 25. UI Integration - "Create" 26. UI Integration - "Open with" 27. Distribution - Chrome Web Store 28. Steps for adding Drive UI integrationPrerequisites: Create a Chrome Web Store listing(Painful !) Install the application from the CWS Enable and configure the Drive SDK in the Google APIs ConsoleIntegration steps: Support OAuth 2.0 server-side flow Read action and file ID from URL parameter 29. Passing context on open & create What happens when somebody launches your app from Drive? URL{ "action" : "create", "parentId" : "0ADK06pfg"Create actions"action" : "open", "ids" : ["0Bz0bd"]Open actions} {} 30. Integrating with Google Drive The Google Picker 31. UI Integration - Embedded file picker 32. Embedding the picker JSgoogle.setOnLoadCallback(createPicker); google.load('picker', '1'); var view = new google.picker.View(google.picker.ViewId.DOCS); view.setMimeTypes("image/png,image/jpeg,image/jpg");function createPicker() { picker = new google.picker.PickerBuilder() .enableFeature(google.picker.Feature.MULTISELECT_ENABLED) .setAppId(YOUR_APP_ID) .addView(view) .setCallback(pickerCallback) .build(); picker.setVisible(true); 33. Handling picker selections JS// A simple callback implementation. function pickerCallback(data) { if (data.action == google.picker.Action.PICKED) { var fileId =[0].id; alert('The user selected: ' + fileId); } } 34. Other features 35. Other Features / tips & tricks Resumable upload & download Indexable text Search! Conversions to native Google Documents Export of native Google Documents in many formats OCR Revisions List installed apps Copy files, Trash files, Touch files User Permissions Shortcuts o Auto-generated MIME type o Contentless 36.


View more >