Search in sources :

Example 1 with GenerateAccessTokenRequest

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();
    }
}
Also used : ArrayList(java.util.ArrayList) IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) GenerateAccessTokenResponse(com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse) GenerateAccessTokenRequest(com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest)

Aggregations

GenerateAccessTokenRequest (com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest)1 GenerateAccessTokenResponse (com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse)1 IamCredentialsClient (com.google.cloud.iam.credentials.v1.IamCredentialsClient)1 ArrayList (java.util.ArrayList)1