Skip to content

Instantly share code, notes, and snippets.

@wendeehsu
Created November 18, 2021 15:34
Show Gist options
  • Save wendeehsu/e5d92ff98f16f6b15e5806e18d5b33b4 to your computer and use it in GitHub Desktop.
Save wendeehsu/e5d92ff98f16f6b15e5806e18d5b33b4 to your computer and use it in GitHub Desktop.
const accountId = "YOUR_ACCOUNT_ID";
function getLocation() {
var service = getService();
if (service.hasAccess()) {
var url = 'https://mybusinessbusinessinformation.googleapis.com/v1/accounts/'+ accountId +'/locations?readMask=name,title';
var response = UrlFetchApp.fetch(url, {
headers: {
Authorization: 'Bearer ' + service.getAccessToken()
}
});
var result = JSON.parse(response.getContentText());
Logger.log(JSON.stringify(result, null, 2));
} else {
var authorizationUrl = service.getAuthorizationUrl();
Logger.log('Open the following URL and re-run the script: %s', authorizationUrl);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment