https://github.com/emicklei/gws
command line tool for using the Google Workspace Admin (formerly GSuite)
https://github.com/emicklei/gws
cli command-line-tool gcp google google-workspace google-workspace-add-on gsuite
Last synced: 10 months ago
JSON representation
command line tool for using the Google Workspace Admin (formerly GSuite)
- Host: GitHub
- URL: https://github.com/emicklei/gws
- Owner: emicklei
- License: mit
- Created: 2019-09-19T07:44:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-04T21:15:34.000Z (about 1 year ago)
- Last Synced: 2025-03-31T03:51:43.411Z (12 months ago)
- Topics: cli, command-line-tool, gcp, google, google-workspace, google-workspace-add-on, gsuite
- Language: Go
- Homepage:
- Size: 207 KB
- Stars: 16
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# gws - command line tool to use the Google Workspace Admin SDK
## features
- list of users
- details of a user
- membership of a user
- management of groups
- list of roles
- user assignments of a role
- list of domains
Any command can produce JSON format using `-json` at the end of the command.
## examples
gws user list
gws user list -limit 4
gws user membership john.doe
gws user membership john.doe@company.com
gws user info john.doe
gws user info john.doe@company.com
gws user aliases john.doe@company.com
gws user suspend angelina "retired"
gws group list
gws group members all
gws group members all@company.com
gws group info somegroup
gws group info somegroup@company.com
gws group delete my-old@company.com
gws group delete my-old@company.com
gws group add my-group this-person other-person@company.com
gws group remove my-group this-person
gws group export -json > all.json
gws --domain company.com group export -csv > company-only.csv
gws role list
gws role assignments _USER_MANAGEMENT_ADMIN_ROLE
gws domain list
gws examples
## requirements
- A Google Cloud Identity domain with API access enabled
- A Google account in that domain with enough administrator privileges
- A Google Cloud Platform project with Admin SDK enabled ( https://console.developers.google.com/apis/library/admin.googleapis.com?project=YOURPROJECT )
### primary domain access
If your Google Workspace (GSuite) account only has "Group Editor" role then you cannot use the short syntax for accounts that require the lookup of the primary domain. You can workaround this missing permission by setting an enviroment variable such as:
export GWS_PRIMARY_DOMAIN=yourhost.com
## install
Installation requires the Go SDK.
go install github.com/emicklei/gws@latest
## tool authentication
- Using the Google Cloud Platform console, create a new OAuth 2.0 client ID credential in the project for which you enabled the Admin SDK.
- Download the JSON file from the list of Credentials (download button on the right).
- Save the file to *gws-credentials.json* in your *home* directory or a *local* directory if you need access to more organisations. *gws* will look for this file in the current directoy first.
## user permissions
*gws* requires the following authentication scopes to be consent per user.
You will be asked to accept those on the first time you use *gws*.
Note that accepting these scopes does not mean you as a user have access ; this is controlled in Cloud Identity (or Google Workspace/GSuite) Admin Console.
- https://www.googleapis.com/auth/admin.directory.user
- https://www.googleapis.com/auth/admin.directory.group ( for group management )
- https://www.googleapis.com/auth/admin.directory.rolemanagement.readonly
- https://www.googleapis.com/auth/admin.directory.domain.readonly
See also https://developers.google.com/admin-sdk/directory/v1/guides/authorizing
## help
Having problems using *gws* ? Read about [known errors](/errors.md)
© 2023+, ernestmicklei.com. MIT License. Contributions welcome.