Reputation: 11
I am building a Chrome web extension app that will allow me to check whether all users in some Google workspace have some settings enabled.
I am not the owner of any of these workspaces, so I will need permission from the workspace admins.
I have created a base chrome app, and am able to load it into chrome. I have used chrome.identity.getAuthToken({interactive:true}, function(token) { ... }
to retrieve an OAuth token from the user using the extension.
My intention was to use this OAuth token to access the google Admin SDK and use the GET https://admin.googleapis.com/admin/reports/v1/usage/users/{userKey or all}/dates/{date}
API call to retrieve the information on user settings, which can be found under the accounts reports. [link]
However, I am unsure as to how I can use the retrieved OAuth token to access this API.
Is the Admin SDK the best way to go about retrieving this data? If so, how do I get access to the Google workspaces using this token?
Upvotes: 1
Views: 116
Reputation: 1333
The Admin SDK is used by Admins only due to the type of data that is handled by this API, if you are trying to get information from other users you will need to find a way to impersonate a Super Administrator as regular users won't be able to perform the API call to UserUsageReport.get()
.
You can use a Service account for user impersonation, there is a good example of how you could work on by using a service account in the following thread however this is made in nodeJS but you will get the idea.
Upvotes: 0