javascript - calling Google bigquery with service account from JS -


i used below code call gogole bigquery chart js using client account. how configure same script google service account, , have p12 key also, can pass key information.

     <html> <head> <script type="text/javascript" src="https://apis.google.com/js/client.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript">     google.load('visualization', '1', { packages: ['geochart'] }); </script> <script>     // update use project id , client id     var project_id = 'xxxxx';     var client_id = 'xxx.apps.googleusercontent.com';      var config = {         'client_id': client_id,                'scope': 'https://www.googleapis.com/auth/bigquery'     };      function runquery() {         var request = gapi.client.bigquery.jobs.query({             'projectid': project_id,             'timeoutms': '30000',             'query': 'select state, avg(mother_age) theav [publicdata:samples.natality] year=2000 , ever_born=1 group state order theav desc;'         });         request.execute(function (response) {             var statevalues = [["state", "age"]];             $.each(response.result.rows, function (i, item) {                 var state = item.f[0].v;                 var age = parsefloat(item.f[1].v);                 var statevalue = [state, age];                 statevalues.push(statevalue);             });             var data = google.visualization.arraytodatatable(statevalues);             var geochart = new google.visualization.geochart(                 document.getelementbyid('map'));             geochart.draw(data, { width: 556, height: 347, resolution: "provinces", region: "us" });         });     }      function auth() {         gapi.auth.authorize(config, function () {             gapi.client.load('bigquery', 'v2', runquery);             $('#client_initiated').html('bigquery client initiated');         });         $('#auth_button').hide();     } </script> </head>  <body> <h2>average mother age @ first birth in 2000</h2> <button id="auth_button" onclick="auth();">authorize</button> <button id="query_button" style="display:none;" onclick="runquery();">run query</button> <div id="map"></div> </body> </html> 

i got know google bigquery documentation - because of security reasons form js can't able use service accounts.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -