{"action":"created","issue":{"url":"https://api.github.com/repos/google/google-visualization-issues/issues/2371","repository_url":"https://api.github.com/repos/google/google-visualization-issues","labels_url":"https://api.github.com/repos/google/google-visualization-issues/issues/2371/labels{/name}","comments_url":"https://api.github.com/repos/google/google-visualization-issues/issues/2371/comments","events_url":"https://api.github.com/repos/google/google-visualization-issues/issues/2371/events","html_url":"https://github.com/google/google-visualization-issues/issues/2371","id":182556735,"number":2371,"title":"Google JS Script error on accessing protected Sheet","user":{"login":"adilyalcin","id":2327953,"avatar_url":"https://avatars.githubusercontent.com/u/2327953?v=3","gravatar_id":"","url":"https://api.github.com/users/adilyalcin","html_url":"https://github.com/adilyalcin","followers_url":"https://api.github.com/users/adilyalcin/followers","following_url":"https://api.github.com/users/adilyalcin/following{/other_user}","gists_url":"https://api.github.com/users/adilyalcin/gists{/gist_id}","starred_url":"https://api.github.com/users/adilyalcin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adilyalcin/subscriptions","organizations_url":"https://api.github.com/users/adilyalcin/orgs","repos_url":"https://api.github.com/users/adilyalcin/repos","events_url":"https://api.github.com/users/adilyalcin/events{/privacy}","received_events_url":"https://api.github.com/users/adilyalcin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-12T15:28:21Z","updated_at":"2016-10-17T15:06:17Z","closed_at":null,"body":"Hi,\r\n\r\nGoogle JS Script throws an internal execution error it received a request into a protected Google Sheet. It should fail gracefully and provide error information on response object, but the official GoogleSheet data endpoint currently returns an invalid function call, and JavaScript execution fails completely.\r\n\r\nThe issue seems to be missing reqId parameter on the response. reqId is available when the sheet is public, but it is not included when sheet is private. This seems to be a bug on Google's implementation.\r\n\r\nTo reproduce:\r\n1) Set a sample sheet to private mode.\r\n2) Make a request using default API: (Replace XYZ with sheet id)\r\n```\r\nvar q=  new google.visualization.Query(\"https://docs.google.com/spreadsheets/d/XYZ/gviz/tq\");\r\nq.send(function(){ ... });\r\n```\r\n\r\n3) The console shows execution error \"Missing query for request id: undefined\". The query callback function isn't called because of API error in executing the injected script / response.\r\n\r\nAfter tracing the problem, I found that the undefined value is \"reqId\" parameter to \r\nthe google.visualization.Query.setResponse function call, which GoogleSheet API returns.\r\n\r\nMore specifically, a call to https://docs.google.com/spreadsheets/d/XYZ/gviz/tq returns (if XYZ is protected sheet)\r\n\r\n```\r\ngoogle.visualization.Query.setResponse({\"version\":\"0.6\",\"status\":\"error\",\"errors\":[{\"reason\":\"access_denied\",\"message\":\"ACCESS_DENIED\",\"detailed_message\":\"This spreadsheet is not publicly viewable and requires an OAuth credential.  For more information, see https://support.google.com/docs/?p=gviz_tq_auth\"}]});\r\n```\r\n\r\nNotice that reqId is not set in this response, but it is expected to be set.\r\n\r\nAnd, if I set the sheet to public, the response is proper, AND includes reqId parameter.\r\n```\r\ngoogle.visualization.Query.setResponse({\"version\":\"0.6\",\"reqId\":\"10\",\"status\":\"ok\", ... });\r\n```\r\n\r\nI tried to set the reqId parameter explicitly, but the response does not recognize / include this parameter. So, https://docs.google.com/spreadsheets/d/XYZ/gviz/tq?tqx=reqId:1 does not work either\r\n\r\nAny help to gracefully detect sheets that are protected, or a solution a fix to Google API implementation, would be appreciated!\r\n\r\nThanks,"},"comment":{"url":"https://api.github.com/repos/google/google-visualization-issues/issues/comments/254234733","html_url":"https://github.com/google/google-visualization-issues/issues/2371#issuecomment-254234733","issue_url":"https://api.github.com/repos/google/google-visualization-issues/issues/2371","id":254234733,"user":{"login":"dlaliberte","id":570125,"avatar_url":"https://avatars.githubusercontent.com/u/570125?v=3","gravatar_id":"","url":"https://api.github.com/users/dlaliberte","html_url":"https://github.com/dlaliberte","followers_url":"https://api.github.com/users/dlaliberte/followers","following_url":"https://api.github.com/users/dlaliberte/following{/other_user}","gists_url":"https://api.github.com/users/dlaliberte/gists{/gist_id}","starred_url":"https://api.github.com/users/dlaliberte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlaliberte/subscriptions","organizations_url":"https://api.github.com/users/dlaliberte/orgs","repos_url":"https://api.github.com/users/dlaliberte/repos","events_url":"https://api.github.com/users/dlaliberte/events{/privacy}","received_events_url":"https://api.github.com/users/dlaliberte/received_events","type":"User","site_admin":false},"created_at":"2016-10-17T15:06:17Z","updated_at":"2016-10-17T15:06:17Z","body":"Thanks.  The lack of a reqId in error responses is now acknowledged by the docs team, and they will be working on a fix.  I don't know how long it will be until the fix shows up, but I suspect it will be a relatively easy fix."}}
{"actor":{"display_login":"dlaliberte"}}