Monday, June 18, 2012 | 4:00 PM
By Nicolas Garnier, Developer Relations
Last November, we launched the OAuth 2.0 Playground, a tool enabling you to easily experiment with the OAuth 2.0 protocol and APIs that use the protocol. We recently added a convenient way for you to test the newly launched Google Drive API by allowing you to open Drive files with the OAuth 2.0 Playground along with extending the capabilities of the Playground to support file upload and multipart requests.
The Drive API uses a per-file security model. When using the https://www.googleapis.com/auth/drive.file scope you will only be able to access the files that your app has created or that were opened through the Google Drive interface with your app. This made it impossible to read any existing Drive files using the OAuth 2.0 Playground by simply authorizing the Drive scope. To make this possible we are providing a way to open files from the Drive UI with the OAuth 2.0 Playground. All you need to do is add the OAuth 2.0 Playground application to Google Drive.
OAuth 2.0 Playground as a Drive app on the Chrome Web Store
To allow you to experiment with the Drive-initiated OAuth 2.0 flow and open existing Drive files using the API we've made the OAuth 2.0 Playground installable as a Drive app from the Chrome Web Store.
After installing the OAuth 2.0 Playground you will be able to open files directly from Drive using the OAuth 2.0 Playground by simply right clicking on a file in Drive > Open with > OAuth 2.0 Playground.
This makes sure the Playground is granted access to the file and then redirects the user to the Playground after initiating an OAuth flow. The Playground will have the auth code and the file metadata URL pre-filled so you'll then be able to conveniently finish the OAuth flow and fetch the file's metadata.
Specify file content as request body
Along with manually specifying text, you can now choose to send file content as part of the request body with the Playground. To do that, simply select a file in the Request Body.
In the case where you choose to specify both some manually entered text and a file as the request body, we will automatically convert your request to a multipart request as shown below.
Content-type: multipart/related; boundary="===============736…
Authorization: OAuth ya29.1234567890
We hope the OAuth 2.0 Playground Drive application and the new file upload features will help you during the development of Drive-enabled web applications. If you have any questions regarding the Drive API don’t hesitate to ask us on Stack Overflow and if you’d like to reach out to the OAuth 2.0 Playground team please do so on our Google Group.
Nicolas Garnier joined Google’s Developer Relations in 2008 and lives in Zurich. He is a Developer Advocate focusing on Google Apps and Web APIs. Before joining Google, Nicolas worked at Airbus and at the French Space Agency where he built web applications for scientific researchers.
Posted by Scott Knaster, Editor