Has there been any updates to perform a OAUTH to a private google sheet?

299 views
Skip to first unread message

Heath Heath

unread,
Oct 22, 2018, 1:26:43 PM10/22/18
to Google Visualization API
Hi, 

I have created a timeline chart using google visualization that pulls data from a private google sheet.
I'd like to share this timeline with other people in my organization. When me or anyone tries to access it now when the sheet is set to private I get an access_denied error. 

My data is connected like so:

  var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/yourapiyourapi/tq?gid=yourgidyourgid&headers=1&tq=' + queryString);
      query.send(handleQueryResponse);

I get an error saying:

Error in query: ACCESS_DENIED This spreadsheet is not publicly viewable and requires an OAuth credential.  For more information, see https://support.google.com/docs/?p=gviz_tq_auth

I've read the documentation but everything on stackoverflow is from 2011 and is outdated. 

The examples here are not clear:


Thank you



Jean-Rémi Delteil

unread,
Oct 23, 2018, 12:21:31 PM10/23/18
to Google Visualization API
Hi 

You have to perfom a Google OAuth authentication, then add the token returned to the request URL in an access_token parameter.

So with your code:

var query = new google.visualization.Query(
      'https://docs.google.com/spreadsheets/d/yourapiyourapi/tq?gid=yourgidyourgid&headers=1&tq=' + queryString + '&access_token='+ accessToken);
);

query.send(handleQueryResponse);


The OAuth needs to be done with the following scope:

And the authenticated user needs to have read access to the spreadsheet, or it will fail.

Heath Heath

unread,
Oct 24, 2018, 6:49:56 PM10/24/18
to Google Visualization API
Hi Jean-Remi,

Thanks for your response.
Could you be a little more specific .

What type of Oath do I need to make? Plain OAuth 2.0  or Google Sign in? and what do I do after I make the authorization? How do I Then pass the authentication back to the query? Is there an example anywhere that makes a Oath for a google spreadsheet that I can follow? 


Thank you, 
Reply all
Reply to author
Forward
0 new messages