OAuth Client Not Found - Google Apps Script - BigQuery

I am trying to use a Script application to upload BigQuery results to a Google spreadsheet. Here is my code

function runQuery() { var projectId = 'xxxxx'; var request = { query: 'select * from ASRLogs.LocationBasedClicks;' }; var queryResults = BigQuery.Jobs.query(request,projectId); var jobId = queryResults.jobReference.jobId; // Check on status of the Query Job. var sleepTimeMs = 500; while(!queryResults.jobComplete) { Utilities.sleep(sleepTimeMs); sleepTimeMs *=2; queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId); } // Get all the rows of the result. var rows = queryResults.rows; while (queryResults.pageToken) { queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId, { pageToken: queryResults.pageToken }); rows = rows.concat(queryResults.rows); } if (rows) { var spreadsheet = SpreadsheetApp.create("BigQuery Results"); var sheet = spreadsheet.getActiveSheet(); // Append the headers var headers = queryResults.schema.fields.map(function(field) { return field.name; }); sheet.appendRow(headers) // Append the results. var data = new Array(rows.length); for (var i = 0; i < rows.length; i ++){ var cols = rows[i].f; data[i] = new Array(cols.length); for (var j =0; j < cols.length; j++){ data[i][j] = cols[j].v; } } sheet.getRange(2,1,rows.length,headers.length).setValue(data); Logger.log('Results spreadsheet created: %s', spreadsheet.getUrl()); } else { Logger.log('No rows returned.') } } 

The error I get is

Error: invalid_client
OAuth client not found.
Request information
- cookie_policy_enforce = false
- scope = https://www.googleapis.com/auth/bigquery https://www.googleapis.com/auth/spreadsheets
- response_type = gsession code
- redirect_uri = https://script.google.com/oauthcallback
- access_type = offline
- confirm_prompt = force
- state = ACjPJvHwuS-sspO-j9b5vlH_Ul4VokI3QRANL-gwa7YWxz6-RFelZBuLQ2aiiGldHRgR89sMnvlgpsmSOnlquEY45oTt1IgZHWfoWq5e52JJPlPw_wpwfwpwfwpwfwpwfwpfpwfwpwfwpfpfp1
- client_id=734978265744@developer.gserviceaccount.com
- hl = en

Am I missing something? I did the following.

  • Enabled BigQuery API on Google Services
  • Included BigQuery in the developer console for the project.
+3
google-apps-script google-bigquery
Feb 25 '14 at 3:52
source share
3 answers

I had the same problem yesterday.

I copied the document several times, which, in turn, copied all the scripts inside it, adding each with "Copy." What I finished was "Copy Copy Copy Copy Copy".

As a last resort, I renamed the Script project to "", and hey presto, it worked out well.

My theory is that since the Script project name is used as the name of the application requesting authorization, there is a certain character limit.

Renaming a project to a shorter name fixes the problem?

+1
Feb 26 '14 at 1:33
source share

Make sure your client ID or secret code does not contain spaces in the code - this was my problem that I did not notice when copying information from the console.

+9
Aug 21 '15 at 10:34
source share

Go to the Consent Screen section of the Google API console (from the sidebar on the left), change the product name and save the changes.

+2
Feb 25 '14 at 17:53
source share



All Articles