Accessing the Administrator Audit Log via Google Script

后端 未结 1 323
温柔的废话
温柔的废话 2021-01-24 11:55

Despite fervent searches, I don\'t believe I have come up with quite the results I am needing. Within the Google Apps for Business Administrator console, under \"Reports\" there

1条回答
  •  爱一瞬间的悲伤
    2021-01-24 12:19

    This is possible using the Google Apps Admin Audit API. This uses OAuth and that is a bit tricky to setup sometimes. You can see the set up process in this video that we did. Except as the example shows, instead of the YouTube APIs enable the Apps Reporting and Audit APIs in the API Console.

    I built out a simple example of this that you can see in operation. Access this URL after having been logged in as the domain admin. It will automatically create a Spreadsheet in your Drive with the latest Audit logs exported. This is a web app that is deployed as "Run as user".

    Sample audit spreadsheet

    I've open sourced this Github here. You should substitute in the right OAuth2 Client ID/Secret. The code is pretty rough so you'll want to clean it up. I am selectively logging a few columns but if you look at the API docs, there are other things you can log as well.

    Once the OAuth token is set up you can have this run on a trigger as well as long as you refresh the token.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题