3
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GAS を使って定期的にgoogle アカウントのパスワードを変更する

Posted at

はじめに

業務で社員が共有しているGoogle アカウントのパスワードを、セキュリティの面で定期的に変える必要があったのでその時のことを残します。

手順

  1. 特権管理者アカウントでスクリプトを開く

  2. サービス "Admin SDK API" の追加

  3. Gas のコード変更

function doGet(e) {
  var address = e.parameter.address
  var newPassword = e.parameter.password
  var user = AdminDirectory.Users.get(address);
  var userKey = user.id
  let data = {
    "password": newPassword, // 仮パスワード
    "changePasswordAtNextLogin": false, // ログイン後にパスワードの変更を強制しない
  }
  AdminDirectory.Users.update(JSON.stringify(data),userKey);
}

おわりに

特権管理者じゃないと、

Not Authorized to access this [resource/api]

怒られるので注意

参考記事

3
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?