1
votes

We would like to provide a list of reference from a public sheets that everyone can view in android. I tried the Quickstart sample from Google which works just fine.

But we would like to minimize the steps (steps like allow access to contacts, choosing google account) since this apps is designed for people who's considering suicide. The list is fill of info about where to ask for help.

I did find a article about how to read a sheet as a InputStream

I would really appreciate if there's more elegant way with Google Sheet API V4

3

3 Answers

1
votes

If the Sheets are shared to "anyone with link" or "public", it might not be necessary to go through the account flow in Android. Choosing an account is mainly to get access to the right credentials, but public sheets can be read anonymously (without credentials) with the API.

1
votes

If you are still looking for an answer, only a single line replacement is needed for this to work:

Credential credential = new GoogleCredential().createScoped(SCOPES);

instead of

Credential credential = authorize();

then you can remove the method authorize() and the corresponding variables

0
votes

I found out there's a setKey method in com.google.api.services.sheets.v4.Sheets. For the third parameter in Builder, as credential, can be null. But will have error "Requests from this Android client application are blocked" if the Key restricted to Android.