Google Apps脚本Users.List()不再返回完整或自定义投影

时间:2018-08-04 02:31:09

标签: google-apps-script google-admin-sdk

function stageGSuiteData(trgtSheet) {
  var response;
  var pageToken;
  var optionalArgs = {
    domain: 'vcastl.org',
    maxResults: 150,
    projection: 'custom',
    customFieldMask: 'Victory_Christian_Academy_Information',
    orderBy: 'email',
    pageToken: pageToken
  };

  do {
    var response = AdminDirectory.Users.list(optionalArgs);
    var users = response.users;

    if (users && users.length > 0) {
      Logger.log('Users on page: %s', optionalArgs.pageToken);

//    for (i = 0; i < users.length; i++) {
        var user = users[0];
        Logger.log('%s', JSON.stringify(user));
        /*
                              user.customSchemas['Victory_Christian_Academy_Information']['VCA_ID',
                              user.customSchemas['Victory_Christian_Academy_Information']['Grade']);
        */
//    }
    }
    else {
      Logger.log('No users found.');
    }

    optionalArgs.pageToken = response.nextPageToken ? response.nextPageToken : optionalArgs.pageToken;
  } while (response.nextPageToken);
}

我一直在使用此脚本将用户列表导入Google表格电子表格。当前状态只是我试图弄清楚如何访问G Suite用户目录中所需的所有数据。身份验证有效,并且所有必需的API均已启用。

上面的代码未返回完整投影或自定义投影,如在optionalArgs调用中使用的Users.list()参数所指定的。无论我在投影字段中设置的值如何,我得到的都是:

{
    "orgUnitPath": "/Students",
    "isMailboxSetup": true,
    "thumbnailPhotoUrl": "https://plus.google.com/_/focus/photos/private/SOME_GUID",
    "id": "SOME_ID",
    "isAdmin": false,
    "suspended": true,
    "isDelegatedAdmin": false,
    "isEnforcedIn2Sv": false,
    "etag": "\"SOME_GUID\"",
    "ipWhitelisted": false,
    "archived": false,
    "changePasswordAtNextLogin": false,
    "customerId": "SOME_ID",
    "nonEditableAliases": ["17johnd@vcastl.org.test-google-a.com"],
    "includeInGlobalAddressList": true,
    "lastLoginTime": "2017-05-22T19:18:04.000Z",
    "primaryEmail": "17johnd@vcastl.org",
    "isEnrolledIn2Sv": false,
    "kind": "admin#directory#user",
    "name": {
        "givenName": "John",
        "familyName": "Doe",
        "fullName": "John Doe"
    },
    "thumbnailPhotoEtag": "\"SOME_GUID\"",
    "creationTime": "2014-08-13T23:54:17.000Z",
    "emails": [{
        "address": "17johnd@vcastl.org",
        "primary": true
    }],
    "agreedToTerms": true,
    "suspensionReason": "ADMIN"
}

这令人沮丧,因为不到24小时之前,完整的和自定义的投影就可以正常工作了。是否可能是由于权限更改或外部原因引起的?我看不到代码本身有什么问题。

0 个答案:

没有答案