use of com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest in project gapic-generator-java by googleapis.
the class AsyncGenerateAccessToken method asyncGenerateAccessToken.
public static void asyncGenerateAccessToken() throws Exception {
// It may require modifications to work in your environment.
try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
GenerateAccessTokenRequest request = GenerateAccessTokenRequest.newBuilder().setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString()).addAllDelegates(new ArrayList<String>()).addAllScope(new ArrayList<String>()).setLifetime(Duration.newBuilder().build()).build();
ApiFuture<GenerateAccessTokenResponse> future = iamCredentialsClient.generateAccessTokenCallable().futureCall(request);
// Do something.
GenerateAccessTokenResponse response = future.get();
}
}
Aggregations