1

After wading through 100+ SO articles, I am acutely aware of how swampy the topic of Google APIs and credentials is, so I'll try to keep this one narrow and focused.

I want to use a Google Spreadsheet to simply read and write pairs of strings for a flashcard app, nothing fancy. For now, I'm willing to use a public spreadsheet to avoid the depression-inducing OAuth2.0 issues.

[Q1] If I use a public google sheet, I only need an API Key and don't need to monkey around with Client IDs and tokens etc. , it should be very straightforward, right ?

I don't want to post my frankenstein code since it contains a mish-mash of snippets I copied from Google API pages and SO. Just want to clear the smoke and get an idea if I'm on the right path.

[Q2] I was tinkering around with 'GoogleAccountCredential' and 'com.google.api.services.sheets', is this all OAuth related and should I throw it out ?

[Q3] How/Where in my code would I 'bring in' the API Key ? I saw some postings where they point to the manifest, so I added this:

    <meta-data
        android:name="com.google.android.sheets.v4.API_KEY"
        android:value="...my API KEY ..."/>

or should I simply skip all the 'sheets' package related 'get/update' commands and try it via straightforward HTTP commands (GET/POST/PUT) and embed the API key via '?key=' in the URL?

Is there some simple code snippet to show how to access Google sheets with only an API key ?!?

Mairyu
  • 809
  • 7
  • 24
  • You may follow this [tutorial](https://developers.google.com/sheets/api/quickstart/android). I don't think that you need the API Key. Just make sure that the field `Package name` is matched with your `src/main/AndroidManifest.xml`. Yes, [`GoogleAccountCredential`](https://developers.google.com/api-client-library/java/google-api-java-client/reference/1.20.0/com/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential) is used to manage authorization and account selection for Google accounts. – abielita Apr 04 '17 at 15:40
  • 1
    yes, have the package matching in my manifest and devcon. Pretty sure the tutorial relies on OAuth since they use GoogleAccountCredential.usingOAuth2. My point was that all this isnt' required for **public** spreadsheets. Were you able to use the snippet succesfully ? – Mairyu Apr 04 '17 at 16:57

1 Answers1

1

You can call setKey("your_key_here") when execute sheet service

reference here : Android Google Sheets API V4 - Update public sheet without OAuth

Mia
  • 1,226
  • 1
  • 19
  • 29