Method Web.Api.Google.discover()


Method discover

Base discover(string api, string version, void|string client_id, void|string client_secret, void|string redirect_uri, void|string|array(string)|multiset(string) scope)

Description

Get a Google API object

Example

This example shows how you can use the Google API to find out all the compute zones that exist at Google Compute Engine.

#define SECRET_FILE     "googleserviceaccount.json"

#define PROJECT         "somegoogleproject"

#define TOKENTIME       3600

string jwt_secret = Stdio.File(SECRET_FILE, "r").read();
Web.Api.Google.Base api = Web.Api.Google.discover("compute", "v1");

void authenticated() {
  if (!api->auth->is_authenticated()
   || api->auth->expires->unix_time() - time(1) < TOKENTIME / 2)
    api->auth->get_token_from_jwt(jwt_secret);
};

authenticated();
mixed allzones = api->resrc->zones->list( ([ "project":PROJECT ]) );