Where is example code showing how to use the Google Data Java Client Library
and its support for OAuth 2.0
with the Google Spreadsheet API
(now called the Google Sheets API
)?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can find a step by step explanation with examples here. As a result, your code might look like this:
(Dec 2016) Much of this question and most answers here are now out-of-date as: 1) GData APIs are the previous generation of Google APIs. While not all GData APIs have been deprecated, all modern Google APIs do not use the Google Data protocol; and 2) Google released a new Google Sheets API v4 (not GData) in 2016. In order to use the new API, you need to get the Google APIs Client Library for Java and use the latest Sheets API, which is much more powerful and flexible than any previous API.
Here's our Java Quickstart code sample to help you get going on using the API -- there's OAuth2 code in it too. Also, here are the JavaDocs reference for the Sheets API which outlines all the classes at your disposal. If you're not "allergic" to Python, I've also made a video walking through the OAuth authorization code and another pair of videos with more "real-world" examples using the Sheets API:
The latest API provides features not available in older releases, namely giving developers programmatic access to a Sheet as if you were using the user interface (create frozen rows, perform cell formatting, resizing rows/columns, adding pivot tables, creating charts, etc.) Also note this API is primarily for programmatic spreadsheet operations & functionality as described above.
To perform file-level access such as uploads & downloads, imports & exports (same as uploads & downloads but conversion to/from various formats), you would use the Google Drive API instead, and here are a pair of examples I've created (also Python):
(*) - TL;DR: upload plain text file to Drive, import/convert to Google Docs format, then export that Doc as PDF. Post above uses Drive API v2; this follow-up post describes migrating it to Drive API v3, and here's a developer video combining both posts.
To learn more about how to use Google APIs (mostly Python or JavaScript), check out the variety of Google developer videos (series 1 and series 2) I'm producing.
Answer moved from original question to match site "Q and A" format.
The
Google Data Java Client Library
supportsOAuth 2.0
. Unfortunately, there are no complete samples in the library showing how to use it with theGoogle Spreadsheet API
.Here is an example that has worked for me. I hope someone find it helpful.
Here the other Class: