use of com.google.cloud.iam.credentials.v1.GenerateIdTokenRequest in project gapic-generator-java by googleapis.
the class SyncGenerateIdToken method syncGenerateIdToken.
public static void syncGenerateIdToken() throws Exception {
// It may require modifications to work in your environment.
try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
GenerateIdTokenRequest request = GenerateIdTokenRequest.newBuilder().setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString()).addAllDelegates(new ArrayList<String>()).setAudience("audience975628804").setIncludeEmail(true).build();
GenerateIdTokenResponse response = iamCredentialsClient.generateIdToken(request);
}
}
use of com.google.cloud.iam.credentials.v1.GenerateIdTokenRequest in project gapic-generator-java by googleapis.
the class AsyncGenerateIdToken method asyncGenerateIdToken.
public static void asyncGenerateIdToken() throws Exception {
// It may require modifications to work in your environment.
try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
GenerateIdTokenRequest request = GenerateIdTokenRequest.newBuilder().setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString()).addAllDelegates(new ArrayList<String>()).setAudience("audience975628804").setIncludeEmail(true).build();
ApiFuture<GenerateIdTokenResponse> future = iamCredentialsClient.generateIdTokenCallable().futureCall(request);
// Do something.
GenerateIdTokenResponse response = future.get();
}
}
Aggregations