公式リファレンスにあるgetUser()をやってみました
https://developers.google.com/apps-script/advanced/admin-sdk-directory
事前準備
実行するには拡張のAPIを有効する必要があります
手順は以下リンクの記事と同じです
AdminDirectoryでUsers.listを取得したい
コード.gs
function getUser() { var userEmail = 'EMAIL'; var user = AdminDirectory.Users.get(userEmail); Logger.log('User data:\n %s', JSON.stringify(user, null, 2)); } |
getUser()を実行するとこのようなデータが返ってきます
ログUser data: { "orgUnitPath": "/", "isMailboxSetup": true, "id": "ID", "isAdmin": true, "suspended": false, "isDelegatedAdmin": false, "isEnforcedIn2Sv": false, "etag": "\"TAG\"", "ipWhitelisted": false, "archived": false, "changePasswordAtNextLogin": false, "customerId": "ID", "nonEditableAliases": ["MAIL.test-google-a.com"], "includeInGlobalAddressList": true, "lastLoginTime": "2018-12-22T23:56:57.000Z", "primaryEmail": "MAIL", "isEnrolledIn2Sv": true, "kind": "admin#directory#user", "name": { "givenName": "FIRST NAME", "familyName": "FAMILY NAME", "fullName": "FULL NAME" }, "creationTime": "2018-09-03T00:15:05.000Z", "emails": [{ "address": "MAIL", "primary": true }, { "address": "MAIL.test-google-a.com" }], "agreedToTerms": true } |
参考
Admin SDK Directory Service
https://developers.google.com/apps-script/advanced/admin-sdk-directory