Script webapp applications: how to authenticate bigquery?

I am trying to run my webapp script applications to execute as a "user accessing webapp", but its bigquery should work like me, the developer. (If I run webapp like me, everything works ...) I looked at the documentation at https://developers.google.com/bigquery/docs/authorization . There are no script applications in the application, so I tried using the javascript example.

<html>
<head>
<script src="https://apis.google.com/js/client.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>

  function auth() {
    gapi.auth.authorize(config, function() {
        gapi.client.load('bigquery', 'v2');
        $('#client_initiated').html('BigQuery client authorized');
        $('#auth_button').fadeOut();
        $('#dataset_button').fadeIn();
    });
  }

  // User Submitted Variables
  var projectNumber = 'XXXXXXXXXX';
  var clientId = 'XXXXXXXXXX.apps.googleusercontent.com';

  var config = {
    'client_id': clientId,
    'scope': 'https://www.googleapis.com/auth/bigquery'
  };

  function listDatasets() {
    var request = gapi.client.bigquery.datasets.list({
      'projectId':projectNumber
    });
    request.execute(function(response) {
        $('#result_box').html(JSON.stringify(response.result.datasets, null));
    });
  }
</script>
</head>
<body>
<button id="auth_button" onclick="auth();">Authorize</button>
<div id="client_initiated"></div>
<button id="dataset_button" style="display:none;" onclick="listDatasets();">Show datasets</button>
<div id="result_box"></div>
</body>
</html>

I created a client ID as a browser application with https://script.google.com as the server address. With the code above, I get this error: I can not read the authorize_m___ undefined property.

: 1) script webapp , javascript ? script?

2) , javascript? , script webapp.... , , ....

+1
1

... : Google-Apps- Script ?

: , , , webapp, BigQuery execs , .

....

+1

Source: https://habr.com/ru/post/1524843/


All Articles