Skip to content

Commit f7fc855

Browse files
authored
Documentation for ComputeEngineCredential signing. (#176)
Adding note about enabling the IAM API and requiring the iam.serviceAccounts.signBlob permission.
1 parent 1b0f734 commit f7fc855

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

oauth2_http/java/com/google/auth/oauth2/ComputeEngineCredentials.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
/**
6262
* OAuth2 credentials representing the built-in service account for a Google Compute Engine VM.
6363
*
64-
* <p>Fetches access tokens from the Google Compute Engine metadata server.
64+
* <p>Fetches access tokens from the Google Compute Engine metadata server.</p>
65+
*
66+
* <p>These credentials use the IAM API to sign data. See {@link #sign(byte[])} for more details.
67+
* </p>
6568
*/
6669
public class ComputeEngineCredentials extends GoogleCredentials implements ServiceAccountSigner {
6770

@@ -294,6 +297,17 @@ public String getAccount() {
294297
return serviceAccountEmail;
295298
}
296299

300+
/**
301+
* Signs the provided bytes using the private key associated with the service account.
302+
*
303+
* <p>The Compute Engine's project must enable the Identity and Access Management (IAM) API and
304+
* the instance's service account must have the iam.serviceAccounts.signBlob permission.</p>
305+
*
306+
* @param toSign bytes to sign
307+
* @return signed bytes
308+
* @throws SigningException if the attempt to sign the provided bytes failed
309+
* @see <a href="https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signBlob">Blob Signing</a>
310+
*/
297311
@Override
298312
public byte[] sign(byte[] toSign) {
299313
BaseEncoding base64 = BaseEncoding.base64();

0 commit comments

Comments
 (0)