Created
November 20, 2019 15:31
-
-
Save jchonde/e06c340ce440fb9089b76701ae95219e 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
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