Google Cloud Identity & Access Management (IAM) lets administrators authorize who can take action on specific resources. These sample applications demonstrate how to interact with Cloud IAM using the Google API Client Library for Java.
The Quickstart does the following:
- Initializes the Resource Manager service, which manages GCP projects.
- Reads the IAM policy for your project.
- Modifies the IAM policy by granting the Log Writer role
(
roles/logging.logWriter
) to your Google Account. - Writes the updated IAM policy.
- Prints all the members in your project that have the Log Writer role
(
roles/logging.logWriter
). - Revokes the Log Writer role.
To build and run the Quickstart, install Maven.
To build the project, run the following command:
mvn clean package
To run the Quickstart, ensure that the Resource Manager API is enabled for your project and that you have set up authentication. For details, see the Before you begin section of the IAM client library Quickstart documentation.
Then, replace the projectId
and member
fields with your
project ID and member ID, and run the following command:
mvn exec:java
For more information, see the IAM client library Quickstart documentation.