close

  
<p> var googleapis_provider = {
  domain: "www.googleapis.com",
  request_token_URL: "https://www.google.com/accounts/OAuthGetRequestToken?scope=https://www.googleapis.com/auth/freebase",
  access_token_URL: "https://www.google.com/accounts/OAuthGetAccessToken",
  user_authorization_URL: "https://www.google.com/accounts/OAuthAuthorizeToken"
};

var api_definition = {
  base: "https://www.googleapis.com",
  service: "freebase",
  version: "v1-sandbox"
};

function api_url(method, params) {
  params = params || {};
  params.key = acre.keystore.get("googleapis_dev")[0];
  var base_url = [api_definition.base, api_definition.service, api_definition.version].join("/");
  var url = base_url + "/" + method;
  return acre.form.build_url(url, params);
}

function login() {
  acre.oauth.get_authorization(googleapis_provider);
}

function is_active_account() {
  return acre.oauth.has_credentials(googleapis_provider);
}

function logout() {
  acre.oauth.remove_credentials(googleapis_provider);
}

function user_info() {
  var url = api_url("user_info");
  var result = JSON.parse(acre.urlfetch(url, "GET", {}, "", true).body);
  console.log(result)
  return result;
}
 </p>

Comments

Hide