I am trying to create tables for a google map in the maps engine. I have added the service account to the access list in the mapsengine admin panel for the map and gave it "can edit" permissions. I also gave it edit permissions in the developer console for the project.
this is where I am sending off for the access token which is sending back a token:
var googleapis = require('googleapis');
function connect() {
var authClient = new googleapis.auth.JWT(
'216755859529-1s2o9qofhd9ea65ang9clpd1936ldfcr@developer.gserviceaccount.com',
'../bin/googleoauth2.pem',
'notasecret',
['https://www.googleapis.com/auth/mapsengine'],
// User to impersonate (leave empty if no impersonation needed)
''
);
authClient.authorize(function(err, tokens) {
if (err) {
console.log(err);
return;
}
else {
console.log(tokens);
}
googleapis.discover('mapsengine', 'v1').execute(function (err, client) {
if (err) {
console.log('Problem during the client discovery.', err);
return;
}
createNewTable();
client.mapsengine.tables.create(mapengine_table_body).withAuthClient(authClient).execute(function (err, response) {
if (err) {
console.log(err);
return;
} else {
console.log(response);
return;
}
});
});
});
}
This is where I am creating the table and sending it:
function createNewTable() {
mapengine_table_body = {
"projectId": projectID,
"name": "World Famous Mountains",
"description": "A partial list of famous mountains in the world.",
"draftAccessList": "Map Editors",
"tags": [
"mountain",
"high places"
],
"schema": {
"columns": [
{
"name": "geometry",
"type": "points"
},
{
"name": "mountain_name",
"type": "string"
},
{
"name": "height",
"type": "integer"
}
]
}
}
}
function start() {
'use strict';
var pck, program;
pck = require('../package.json');
program = require('commander');
program
.version(pck.version)
.option('-r, --run', 'Run')
.parse(process.argv);
console.log('running:');
if (program.run) {
connect();
}
}
The ProjectId I am getting from the url when viewing the project. I have looked through as much documentation as I can find, but I haven't been able to figure this one out. Thanks.