Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jchonde/e06c340ce440fb9089b76701ae95219e to your computer and use it in GitHub Desktop.
Save jchonde/e06c340ce440fb9089b76701ae95219e to your computer and use it in GitHub Desktop.
function listAccounts() {
var accounts = Analytics.Management.Accounts.list();
if (accounts.items && accounts.items.length) {
for (var i = 0; i < accounts.items.length; i++) {
var account = accounts.items[i];
if (account.permissions.effective.indexOf("EDIT") !== 1) {
continue;
}
var body = {
permissions: {
local: ["READ_AND_ANALYZE"]
},
userRef: {
email:
"xxxx"
}
};
Analytics.Management.AccountUserLinks.insert(body, account.id);
}
} else {
Logger.log("No accounts found.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment