Google Admin SDK 用户观看不会推送有关角色更改或移动组织单位的通知

Google Admin SDK users watch doesn't push notifications for role changes or moving org units

我订阅并测试了 [1] 中列出的所有事件。 "add":用户创建的事件 "delete": 用户删除事件 "makeAdmin":用户管理员状态更改事件 "undelete": 用户取消删除事件 "update":用户更新事件

我在 Java 中为 OAuth2 手表订阅使用了市场凭据。这适用于添加用户、删除用户和更改用户名("update" 事件)。但是,将用户移动到不同的组织单位、添加或删除超级管理员角色不会触发任何通知。在这种情况下,我希望发生 "update" 事件。

有没有人幸运地收到 Google 组织单位或域管理员更改的推送通知?

public static final String[] SUBSCRIBE_EVENTS = { "add", "delete", "undelete", "update", "makeAdmin" };


// OAuth access.
HttpTransport httpTransport = new NetHttpTransport();
JacksonFactory jsonFactory = new JacksonFactory();
Collection<String> scopes = new ArrayList<String>();
scopes.add("https://www.googleapis.com/auth/admin.directory.user.readonly");

GoogleCredential credential;
try {
  credential = new GoogleCredential.Builder()
      .setTransport(httpTransport)
      .setJsonFactory(jsonFactory)
      .setServiceAccountId(Settings.OAUTH_MARKETPLACE_ACCOUNT_ID)
      .setServiceAccountScopes(scopes)
      .setServiceAccountUser(currentUserEmail)
      .setServiceAccountPrivateKeyFromP12File(
          new java.io.File(Settings.OAUTH_MARKETPLACE_CERTIFICATE_KEY_PATH)).build();

} catch (Exception e) {
  LOG.log(Level.SEVERE, "OAuth credential error.", e);
  return false;
}

Directory directory =
    new Directory.Builder(httpTransport, jsonFactory, credential)
        .setApplicationName(Settings.OAUTH_APPLICATION_NAME)
        .setHttpRequestInitializer(credential).build();

for (final String event : SUBSCRIBE_EVENTS) {
  Channel channel = new Channel();
  channel.setId(UUID.randomUUID().toString());
  channel.setType("web_hook");
  channel.setAddress(watchUrl);

  try {
    StringBuilder tokenSB = new StringBuilder();
    tokenSB.append("domain=").append(URLEncoder.encode(apiDomain, "UTF-8"));
    tokenSB.append("&event=").append(URLEncoder.encode(event, "UTF-8"));
    channel.setToken(tokenSB.toString());
  } catch (UnsupportedEncodingException e) {
    LOG.log(Level.SEVERE, "OAuth users.list.watch encoding error", e);
    break;
  }

  try {
    Watch watch = directory.users().watch(channel);
    watch.setDomain(apiDomain);
    watch.setEvent(event);
    watch.setProjection("full");
    watch.setViewType("admin_view");

    watch.execute();

  } catch (Exception e) {
    LOG.log(Level.SEVERE, "OAuth users.list.watch error", e);
  }
}
  1. https://developers.google.com/admin-sdk/directory/v1/reference/users/watch

这似乎是我们的推送通知系统中的错误。如果您在这里提出问题,我们可以向您更新问题的状态:https://code.google.com/a/google.com/p/apps-api-issues/issues/entry?labels=Type-Defect,API-Admin