Created
November 18, 2021 15:34
-
-
Save wendeehsu/e5d92ff98f16f6b15e5806e18d5b33b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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