将Google API Node.js客户端库与AppEngine Cloud Endpoints一起使用?

时间:2014-03-18 08:49:13

标签: google-app-engine google-cloud-endpoints google-api-nodejs-client

我编写了一个使用Cloud Endpoints的Java App Engine应用程序。我想从Node.js应用程序与这些端点进行通信。为此可以使用google-api-nodejs-client吗?

我已经尝试过这个:

var googleapis = require('googleapis');

googleapis
    .discover('myapiname', 'v1dev', {baseDiscoveryUrl: 'http://localhost:8888/_ah/api/discovery/v1/apis/'})
    .execute(function(err, client) {
        console.log(err);
        console.log(client);
        client.myapiname.domains.list().execute(function(err, resp) {
            console.log(resp);
        });
    });

但是库没有发现我的端点,回调为err返回null而client看起来像这样:

{ clients: [],
  ops: {},
  authClient: null,
  undefined: 
   { apiMeta: '<html><head><title>Error 404</title></head>\n<body><h2>Error 404</h2></body>\n</html>',
     authClient: null,
     defaultParams: null } }

我用myapiname&#39;取代了我真正的api名字。当然,URL http://localhost:8888/_ah/api/discovery/v1/apis/是可以访问的(如果我在同一台计算机上的浏览器中打开它,它会返回正确的发现JSON。)

1 个答案:

答案 0 :(得分:0)

您是否尝试使用部署在Google应用引擎上的某些虚拟机上的代码使用相同的代码。  我尝试使用我们的应用引擎网址,它就像魅力一样。